Peter Dimov wrote:
Kevin Wheatley reports that the assert( res == WAIT_OBJECT_0 ) is failing for him on Windows. Printing res (WAIT_FAILED) or GetLastError() ("invalid handle" would be my bet) won't give us much information as to whether the assert is failing due to double thread::join, thread::join on a default-constructed thread, or an internal error in Boost.Threads.
To me the most obvious thing missing is something like: void thread::join() { assert(m_joinable); int res = 0; rest of function.... at the start of the function, that should catch some of the programming errors across all platforms and at least says that the assumption is that join is only valid on joinable threads (those non-default constructed, not already joined threads). At least I think we could all agree on that :-) but then does this mean there should be a bool thread::isJoinable() const { return m_joinable; } function too? this may lead to lots of "if (thrd.isJoinable()) thrd.join();" which I'm personally not too happy of else where in threads there are somethings which suggest code more like: void thread::join() { assert(m_joinable); if (!m_joinable) return; int res = 0; rest of function.... for instance this is effectively what goes on in thread_group::remove_thread() withthe if clause after the assert, in that function there is a comment which even indicates that it is potentially unclear what the appropriate level of error this should be. Kevin -- | Kevin Wheatley, Cinesite (Europe) Ltd | Nobody thinks this | | Senior Technology | My employer for certain | | And Network Systems Architect | Not even myself |