Task #1160
closed
- Description updated (diff)
std::future
implies multi-threading.
What I desire is a mechanism to bundle success and failure callbacks.
- 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 when Deferred::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
Also available in: Atom
PDF