Actions
Task #1160
closedlightweight future abstraction
Start date:
01/27/2014
Due date:
% Done:
0%
Estimated time:
2.00 h
Updated by Junxiao Shi almost 11 years ago
- Description updated (diff)
std::future
implies multi-threading.
What I desire is a mechanism to bundle success and failure callbacks.
Updated by Junxiao Shi almost 11 years ago
- Status changed from New to Rejected
- Target version set to Mock
After some thinking, it becomes clear that a jQuery-like future abstraction is not feasible in C++.
If Deferred::resolve
is invoked before Deferred::done
, the handler passed to Deferred::done
should be invoked with the argument passed to Deferred::resolve
. This implies that the argument should be stored in Deferred.
- store as a reference: the caller of
Deferred::resolve
may go away whenDeferred::done
is invoked. - store as a pointer to a heap allocated object: it's unclear who should delete this object.
- store as a shared_ptr: complexity on caller of
Deferred::resolve
to create shared_ptr - store a copy: cost of copying; many types are noncopyable
Actions