The delegate could send a message to user code in another
thread/fiber. In any case it removes a blocking get_result()
and possibly the need for get_result_timeout().
That sounds interesting, and I will look into it. (Questions to
follow, no doubt).
But we've gone down a path at a specific s
On Tuesday, 7 July 2015 at 16:41:41 UTC, Frank Pagliughi wrote:
Instead of pulling values out, have you considered pushing
them? E.g. by supplying a delegate that gets called when the
asynchronous action completed.
I've always been on the fence about push vs pull when writing
libraries of thi
It seems that just casting the Token (future) as "shared" to get
it across the thread boundary works. From inside my thread:
receive(
(shared(Token) tok) {
int res = do_something();
(cast(Token)tok).set_result(res);
...
And then in the method which is exposed to the user
Instead of pulling values out, have you considered pushing
them? E.g. by supplying a delegate that gets called when the
asynchronous action completed.
I've always been on the fence about push vs pull when writing
libraries of this type. The callback/delegate method is probably
more powerful a
On Monday, 6 July 2015 at 20:56:04 UTC, Frank Pagliughi wrote:
void set_result(int retCode) {
synchronized (mut) {
this.retCode = retCode;
completed = true;
cond.notify();
}
}
int get_result() {
synchronized (mut) {
while (!completed)
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 ac
On Monday, 6 July 2015 at 20:56:04 UTC, Frank Pagliughi wrote:
void set_result(int retCode) {
synchronized (mut) {
this.retCode = retCode;
completed = true;
cond.notify();
}
}
int get_result() {
synchronized (mut) {
while (!completed)
On Mon, 06 Jul 2015 20:56:03 +, Frank Pagliughi wrote:
> Hello All,
>
> I'm trying to figure out how to create a shared object that can be used
> to track asynchronous operations. Something that can be used like:
>
>Token tok = mything.start_something();
>
>// do something else for
Hello All,
I'm trying to figure out how to create a shared object that can
be used to track asynchronous operations. Something that can be
used like:
Token tok = mything.start_something();
// do something else for a while
int n = tok.get_result(); // Block until result is ready
The