Creating a future/promise object

Frank Pagliughi via Digitalmars-d digitalmars-d at puremagic.com
Tue Jul 7 06:17:25 PDT 2015


Thanks for the replies!

The parallelism Task is *doing* what I would like to do, but the 
package does not seem to expose the underlying components. The 
'Task' essentially has a thread, future, and promise. I already 
have a long-running thread hidden inside of 'mything' which is 
serializing access to the communications channel/socket. I send 
it tasks with send() / receive() operations. So I just need the 
future/promise part.

Or, I would need a way to execute the Task in a specific thread, 
like:
   executeInThread(Tid t);

I will try to dig through the parallelism code to see how it is 
implemented.

As for my attempted implementation, that's a typical pattern with 
condition variables. The mutex is required because the condition 
variable needs a specific lock. And there's no deadlock because 
the condition variable releases the lock when you call 
cond.wait().


More information about the Digitalmars-d mailing list