Actor based concurrency and cancellation

Posted by Akash on Programmers See other posts from Programmers or by Akash
Published on 2012-03-25T08:34:46Z Indexed on 2012/03/27 17:41 UTC
Read the original article Hit count: 285

Filed under:

I'm reading about actor based concurrency and I appreciate the simplicity of actors sequentially processing messages on a single thread. However there is one scenario that doesn't seen possible.

Suppose that actor A sends a message to actor B, who then performs some long running task and returns a completion message to actor A. How can actor A force actor B to cancel the long running task after it has started?

If actor B is running the task in its message queue thread, it won't pick up the cancellation message until it had completed the task; if actor B runs the task in a background thread then it seems to be violating the principle of actors.

Is there a common way that this scenario is handled with actors? Or does each actor language/framework take a different approach? Or is this not a suitable problem to tackle via actors?

© Programmers or respective owner

Related posts about untagged