Great article, thanks. But what about my first question? Is there no way to exit a process in a similar way?
Great article, thanks. But what about my first question? Is there no way to exit a process in a similar way?
Oops. Yeah, whenever I said "process" I meant "thread" :P
Just return from your concurrent function then. You cannot abort a running concurrent function from outside - it could render your application in an unpredictable state. If you want to be able to abort an inprogress operation, you have to use some other approach (i.e. the "solving the problem step by step" one from the article - either in an external thread or in the main thread).
It's a multi-branch recursive function, returning to the bottom wouldn't be easy.
I'm not - I'm trying to abort it from the inside at a safe point in response to a flag being set.
To sum things up, I just want to be able to call a function from a thread that would make the thread just drop everything and stop messing with my data structuresCan I do that?
You can throw exceptions from your function and catch them at the upper-most level and then return from the thread function.
Good suggestion. Thanks again.
Bookmarks