我现在用 Microsoft Parallel Patterns Library (PPL) http://msdn.microsoft.com/en-us/library/dd492418.aspx
感觉上,任何物件只要被包进task lambda (closure)里面,它们的生命周期就好像没
有底似的。例子∶
(1) Create task completion event ( http://msdn.microsoft.com/en-us/library/hh750136.aspx )
(2) Create a lambda task as a continuation on that task completion event.
the lambda task captures some variables by reference count (using std::
shared_ptr )
e.g.
>> std::shared_ptr<...> something;
>> concurrency::task_completion_event tce;
>> concurrency::task(tce).then( [something] () { something.do(); } );
(3) Never set the task completion event. For example, it may be dependent on
some user action, but that user action never happens.
The captured std::shared_ptr variable seems to have leaked?