use c ++ packaged_task to build a producer-consumer pattern

I am trying to packaged_task to create a producer-consumer patten code is as following : test_thread9_producer1 and test_thread9_producer2 push task into a queue and test_thread9_consumer1 retrieve task from the queue to execute However when running

Implementing a simple and generic thread pool in C ++ 11

I want to create a thread pool for experimental purposes (and for the fun factor). It should be able to process a wide variety of tasks (so I can possibly use it in later projects). In my thread pool class I'm going to need some sort of task queue. S

How to create a packaged_task with a member function?

On the program below, I'm trying to create a packaged_task with a member function: #include <future> using namespace std; struct S { int calc(int& a) { return a*a; } }; int main() { S s; auto bnd = std::bind(&S::calc, s); std::packaged_task&

When to use the promise on async or packaged_task?

When should I use std::promise over std::async or std::packaged_task? Can you give me practical examples of when to use each one of them?std::async std::async is a neat and easy way to get a std::future, but: Not always it starts a new thread; pass s

How do I create a packaged_task with parameters?

Following this excellent tutorial for futures, promises and packaged tasks I got to the the point where I wanted to prepare my own task #include <iostream> #include <future> using namespace std; int ackermann(int m, int n) { // might take a wh