Project

General

Profile

Actions

Task #1160

closed

lightweight future abstraction

Added by Junxiao Shi almost 11 years ago. Updated over 10 years ago.

Status:
Rejected
Priority:
High
Assignee:
Category:
Core
Target version:
Start date:
01/27/2014
Due date:
% Done:

0%

Estimated time:
2.00 h

Description

Provide a mechanism similar to jQuery.Deferred.

Actions #1

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.

Actions #2

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 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
Actions #3

Updated by Junxiao Shi over 10 years ago

  • Category set to Core
Actions

Also available in: Atom PDF