packaged-task Questions
4
Solved
While working with the threaded model of C++11, I noticed that
std::packaged_task<int(int,int)> task([](int a, int b) { return a + b; });
auto f = task.get_future();
task(2,3);
std::cout <...
Hosea asked 9/8, 2013 at 9:34
2
Solved
class MoveOnlyOperation
{
public:
MoveOnlyOperation() = default;
MoveOnlyOperation(const MoveOnlyOperation&) = delete;
MoveOnlyOperation(MoveOnlyOperation&&) = default;
int operato...
Kamikamikaze asked 26/2, 2018 at 19:21
3
Solved
I got to know the reason that future returned from std::async has some special shared state through which wait on returned future happened in the destructor of future. But when we use std::pakaged_...
Mastermind asked 11/9, 2020 at 8:43
1
Solved
I have been trying to capture packaged_task into lambda, but I've failed.
I understand move-semantics at all, also read some modern literature and I was thinking I didn't miss anything. Also I hav...
Ashkhabad asked 16/5, 2020 at 12:26
3
Solved
I am analysing the following code snippet and am trying to understand it in detail:
template<typename FUNCTION, typename... ARGUMENTS>
auto ThreadPool::add( FUNCTION&& Function, ARGU...
Placia asked 10/10, 2017 at 8:29
1
Solved
Is it safe to create a std::future from a std::packaged_task, which executes on a separate thread, but not always retrieve its result?
#include <future>
#include <thread>
class Result...
Bamby asked 31/5, 2016 at 2:55
2
Solved
I've been trying more about multi threaded programming in c++, and i was having difficulty understanding std::promise so i began searching for answers on this website, and low and behold, there is ...
Leeuwarden asked 2/12, 2015 at 1:52
2
Solved
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 threa...
Clichy asked 26/6, 2015 at 11:40
1
I recently ran valgrind --tool=helgrind on my project and got a warning "possible data race", which I thought was concerning. However, even this simple test program leads to this message:
#include...
Egregious asked 11/12, 2014 at 13:32
2
Solved
I'm encountering something very weird when using packaged tasks. When reading ~packaged_task I get the impression that if a std::packaged_task is destroyed before it is executed, the promise will b...
Remanent asked 10/9, 2014 at 10:8
2
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?
Forewing asked 18/7, 2013 at 17:12
3
Solved
Using MSVC2012,
The following code will compile and run as expected
std::packaged_task< int() > task( []()->int{ std::cout << "hello world" << std::endl; return 0; } );
std::...
Devalue asked 7/2, 2013 at 5:57
1
Solved
My assumption is that packaged_task has a promise underneath. If my task throws an exception, how do I route that to the associated future? With just a promise I could call set_exception
– how do ...
Transgression asked 2/5, 2013 at 17:59
1
Solved
It seems that unless you call std::async a std::future will never be set to any other state than future_status::deferred unless you call get or wait on the future. wait_for & wait_until will co...
Presentationism asked 8/10, 2012 at 3:10
2
Solved
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 name...
Audieaudience asked 25/9, 2011 at 20:44
1
© 2022 - 2024 — McMap. All rights reserved.