Tasks

Executing a Future in a Separate Thread with Coroutines

This post concludes my posts about co_return in C++20. I started with an eager future, and continued with a lazy future. Today, I execute the future in a separate thread using coroutines as an implementation detail.

Read more
Views: 17610

Lazy Futures with Coroutines

Based on the coroutines-based implementation of a simple future in my last post "Implementing Simple Futures with Coroutines", I want to go today one giant step further. I analyze the workflow of the simple future and make it lazy.

Read more
Views: 15487

Implementing Simple Futures with Coroutines

Instead of return, a coroutine uses co_return returning its result. In this post, I want to implement a simple coroutine using co_return.

Read more
Views: 32603

Synchronization with Atomics in C++20

Sender/receiver workflows are pretty common for threads. In such a workflow, the receiver is waiting for the sender's notification before it continues to work. There are various ways to implement these workflows. With C++11, you can use condition variables or promise/future pairs; with C++20, you can use atomics.

Read more
Views: 29813

The End of my Detour: Unified Futures

After the last post to executors, I can finally write about the unified futures. I write in the post about the long past of the futures and end my detour from the C++ core guidelines.

Read more
Views: 24062

C++ Core Guidelines: More Rules about Concurrency and Parallelism

Writing multithreading programs is hard, even harder if the program should be correct. The rules of the C++ Core Guidelines guide you to writing correct programs. The rules of this post will deal with data races, sharing of data, tasks, and the infamous keyword volatile.

Read more
Views: 27294

std::future Extensions

Tasks in the form of promises and futures have in C++11 an ambivalent reputation. On the one hand, they are much easier to use than threads or condition variables; conversely, they have a significant deficiency. They can not be composed. C++20 will overcome this deficiency.

Read more
Views: 56712

Multithreaded: Summation with Minimal Synchronization

Until now, I've used two strategies to summate a std::vector. First, I did the whole math in one thread (Single Threaded: Summation of a vector); second multiple threads shared the same variable for the result (Multithreaded: Summation of a vector). In particular, the second strategy was extremely naive. In this post, I will apply my knowledge of both posts. My goal is that the thread will perform their summation as independently from each other as possible and therefore reduce the synchronization overhead. 

Read more
Views: 23927

Thread Synchronization with Condition Variables or Tasks

In case you use promise and future to synchronize threads, they have much in common with condition variables. But most of the time, tasks are the better choice.

Read more
Views: 66678

The Special Futures

The parent of a thread has to take care of their child. The parent can wait until his child is done or detach himself from his child. But that is not new. But that will not hold for std::async. The big charm of std::async is that the parent has not taken care of his child.

Read more
Tags: async, Tasks
Views: 31298

Stay Informed about my Mentoring

 

Mentoring

English Books

Course: Modern C++ Concurrency in Practice

Course: C++ Standard Library including C++14 & C++17

Course: Embedded Programming with Modern C++

Course: Generic Programming (Templates)

Course: C++ Fundamentals for Professionals

Course: The All-in-One Guide to C++20

Course: Master Software Design Patterns and Architecture in C++

Subscribe to the newsletter (+ pdf bundle)

All tags

Blog archive

Source Code

Visitors

Today 1704

Yesterday 4344

Week 38582

Month 18828

All 12097037

Currently are 152 guests and no members online

Kubik-Rubik Joomla! Extensions

Latest comments