|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-08-23 05:26:38
Ending a thread:
No library support is necessary. A thread can terminate itself by throwing
an exception of type "thread_end" or a type derived from thread_end.
When a thread_end (or derived) exception escapes from the thread procedure
(function object operator()), the thread is terminated as if it had returned
normally.
When an exception other than thread_end (or derived) escapes from the thread
procedure, {boost,std}::thread_terminate() is called. It does nothing by
default unless a user-specific handler has been installed via
set_thread_terminate(handler), in which case that handler is invoked. The
thread is then terminated as if it had returned normally.
When a thread_end (or derived) exception escapes from main(), the main
thread (but not the process) is terminated.
When an exception other than thread_end (or derived) escapes from main(),
the behavior is as already specified in the standard.
Canceling a thread:
When thread::cancel() (nonstatic) is called the thread goes into canceled
state.
When a canceled thread calls a function that is a cancelation point [and
std::uncaught_exception() returns false?], this function throws an exception
of type thread_end (or derived.)
Cancelation points are mutex::lock (by default), condition::wait,
thread::sleep, thread::yield, thread::join, thread::cancelation_point
(static), thread::cancel.
Suspending/resuming a thread:
When thread::suspend() (nonstatic) is called, that thread's execution is
suspended by the system no later than the first encountered cancelation
point.
thread::suspend is a cancelation point.
thread::resume() (nonstatic) resumes a suspended thread.
Opinions? This behavior (with one minor exception) is implementable now, at
least on paper.
-- Peter Dimov Multi Media Ltd.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk