From: Roland (roland.schwarz_at_[hidden])
Date: 2003-12-30 05:01:41


Some thoughts about thread cancellation:

When it comes to talk about cancellation I always read this in the context
of cancelling the thread of execution.

The "passive monitor" pattern brought me to the question:
Wouldn't it be easier to cancel the objects instead?

Say you have an IO object and start a read on it:

try {
    IO.read(buffer);
}
catch(cancelexception& e) {
   cout << e.what();
  // clean up and exit the thread or acquire a new (backup) IO object
}

And from within another thread:

....

IO.cancel();

....

This would also be handy in the case where mutiple threads are blocked on the IO object,
since I do not need to remeber which threads are blocked, and the thread is responsible
for its own lifetime. (Process shutdown of course is a different matter.)

Is there already some discussion about this on the net?
If anyone knows, could he/she point me to the relevant pages please?
(I did not find relevant material so far.)

Thank you,
Roland