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
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
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&
From the C++11 book I recently got, I am trying to build the example on page 123 (packaged_task 5.3.5.2) and after a few things to make this work with XCode, I have a couple of questions: First, there seems to be a requirement to pass a function poin
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
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
I'm trying to construct a work queue of functions that need to be executed by one thread and can be fed by many threads. To accomplish this, I was planning on using the boost::packaged_task and boost::unique_future. The idea would be you would do: Fo