Topic: Defect Report: library issue 1050: Wrong change for promise::get_future()
Author: "Thomas J. Gritzan" <phygon_antispam@gmx.de>
Date: Fri, 3 Apr 2009 10:31:30 CST Raw View
Comment on library issue 1050. "Response to UK 340"
promise::get_future() must not invalidate the state of the promise object.
A promise is used like this:
promise<int> p;
unique_future<int> f = p.get_future();
// post 'p' to a thread that calculates a value
// use 'f' to retrieve the value.
So get_future() must return an object that shares the same associated
state with *this.
But still, this function should throw an future_already_retrieved error
when it is called twice.
packaged_task::get_future() throws std::bad_function_call if its future
was already retrieved. It should throw
future_error(future_already_retrieved), too.
Proposed resolution:
Replace p12/p13 30.6.6 [futures.promise]:
Throws: future_error if the future has already been retrieved.
Error conditions: future_already_retrieved if the future associated with
the associated state has already been retrieved.
Postcondition: The returned object and *this share the associated state.
Replace p14 30.6.8 [futures.task]:
Throws: future_error if the future has already been retrieved.
Error conditions: future_already_retrieved if the future associated with
the task has already been retrieved.
Postcondition: The returned object and *this share the associated task.
--
Thomas J. Gritzan
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]