<@UAYSNLD7T> an actor would be a fine approach if ...
# coroutines
b
@nwh an actor would be a fine approach if they need to be serially executed
n
By serially executed, do you mean sequentially? I'm not familiar with that term
d
yes, where every line of code in your actor lambda is executed as if it's single threaded
n
How would I stop execution if the actor is closed? Say, if one operation fails, is there some kind of mechanism for knowing I shouldn't perform the next one, or should I just use `return`s and such
l
@nwh The actor can have a parent
Job
which you can cancel
n
@louiscad Does that mean I'll just have to pass around the
Job
instance and check if it's cancelled?
b
@nwh it depends on how your operations are setup, how they report failure, and who is doing the cancelling. There are several options. If the actor is in control, you could just throw exceptions and catch them in the actor and then
return
(or
continue
, if you want to restart your loop)
if you want to cancel from outside the actor, you can use a job like Lous CAD said
n
@bj0 Yeah, not sure if the individual processes will be performing the cancellation or not. It's not a loop, it's several steps, and there is data being passed between each step
I think I'm probably over-complicating it
b
i mean the individual process can throw an exception and the actor can catch it and then decide to quit
or you could use return values, but it's a good use case for exceptions