Questions tagged [std-future]

The [c++11] std::future object can be used to retrieve the result of the asynchronous operations or any exceptions it throws.

An asynchronous operation can be created via:

  • std::async
  • std::packaged_task
  • std::promise

Each of the above can provide a std::future object to the creator of that operation.

A std::future object (let name it f) can be used to

  • wait for the result: f.wait(), f.wait_for(duration), f.wait_until(time_point)
  • retrieve the value (if ready): f.get()
  • share its state (std::shared_future): f.share(), f.valid()

More here.

62 questions
0
votes
1 answer

Wake a deferred task object without invoking future.get()

What happens when you call std::future::wait_for on a deferred task object? Ideally I would like to wake a deferred task but not take the hit of processing the task in the current thread.
Ram
  • 3,045
  • 3
  • 27
  • 42
0
votes
1 answer

Using c++11's std::async inside an abstract base class

Why doesn't making threads like this work inside of an abstract base class? I'm trying to abstract away all of the multithreading details for users who derive from this base class. I don't understand why it says "no type named 'type'" when I…
Taylor
  • 1,797
  • 4
  • 26
  • 51
1 2 3 4
5