https://kotlinlang.org logo
Title
b

bj0

07/11/2018, 11:11 PM
@nwh an actor would be a fine approach if they need to be serially executed
n

nwh

07/11/2018, 11:15 PM
By serially executed, do you mean sequentially? I'm not familiar with that term
d

Daniel Tam

07/12/2018, 12:36 AM
yes, where every line of code in your actor lambda is executed as if it's single threaded
n

nwh

07/12/2018, 1:16 AM
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

louiscad

07/12/2018, 7:51 AM
@nwh The actor can have a parent
Job
which you can cancel
n

nwh

07/12/2018, 5:08 PM
@louiscad Does that mean I'll just have to pass around the
Job
instance and check if it's cancelled?
b

bj0

07/12/2018, 7:36 PM
@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

nwh

07/12/2018, 7:44 PM
@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

bj0

07/12/2018, 8:02 PM
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