Suppose I have a thread that is running a packaged_task
. I am not interested in the return value of the task and only wish for the thread to run the task silently in the background. As such, I never use the get_future()
to obtain any handle on the promise
of the task.
My concern is, when the packaged_task
is completed and the destructor ~packaged_task
is called, it states that
As with std::promise::~promise, if the shared state is abandoned before it was made ready, an std::future_error exception is stored with the error code std::future_errc::broken_promise).
My question is, assuming I never get a handle on the promise
via get_future()
, can I safely ignore the std::future_errc::broken_promise
exception?
My question is motivated by trying to modify this thread pool library to ignore return values since I'm only using it with void
-returning functions. I was thinking to simply change the return type of the enqueue
function to return void and remove the get_future()
on line 72.