Early Access Loom Builds

Dávid Karnok akarnokd at gmail.com
Mon Jul 29 13:16:20 UTC 2019


Thanks. I was hoping for some details on Continuation and
ContinuationScope, but those are TBD. I'd like to ask a question because of
that.

1) What happens when Continuation.run() is active but hasn't reached a
yield() point and I call Continuation.run()
from another thread?

Example use case: let's assume a generator is emitting values based on how
many such values have been requested. When the requests stop, the generator
should yield until the requests happen again, which requests would then
call run(). A race condition is possible when the generator sees the
current requested amount to be zero, the other thread bumps this amount and
calls run(), then the generator thread issues yield().

2) What happens if multiple threads call Continuation.run()?

Example use case: a consumer collects values from multiple async sources.
The sources post to a (shared) queue and then would signal the consumer
that data is ready. The consumer would check the queue and if it is/becomes
empty, it would yield(). A race condition is possible when both async
sources post to the queue and then both would issue run() to indicate the
consumer can resume. Naturally, this can be turned into the case of
question 1) by making sure only one of the sources can issue a run() at a
time thus we are back to run()-yield() race.


Alan Bateman <Alan.Bateman at oracle.com> ezt írta (időpont: 2019. júl. 29.,
H, 14:51):

> On 28/07/2019 23:22, Dávid Karnok wrote:
> > Great!
> >
> > Could you point me to the API docs of the relevant components (i.e.,
> which
> > classes to look at) and any up-to-date basic usage examples?
> >
> The API docs are linked from the page with the build. If you type
> "Fiber" or "FiberScope" into the search box then it should get you
> going. There's a simple example in the FiberScope class description.
> There is ongoing churn in the API but when it's a bit more stable then
> we'll put examples on the wiki to make it easier to get started.
>
> -Alan
>


-- 
Best regards,
David Karnok


More information about the loom-dev mailing list