|
Threads-Devel : |
Subject: Re: [Threads-devel] unbind passed function to the thread constructor after real thread exits
From: dadrus_at_[hidden]
Date: 2009-02-24 03:51:57
Hi,
Sorry that i was not precise enough in my initial post.
> That's just not how the library works. The function is destroyed along
> with the remainder of the thread's resources when the thread has
> completed and the thread has been joined or detached.
> OK, I see the problem. It's just not how the library is designed.
OK, I understand. Is there something to said against an additional wrapper for the provided functor and extend thread_data_base to a new function which would be called after exit of the run() method (like run_thread_exit_callbacks()) so any non thread relevant resources will be cleared?
By the way, bacause i'm talking about extensions: Did you planed to introduce user specific interruption points?
Something like that:
Imagine you're working with windows pipes und uses the Overlapped structure to be able to cancel any receive/accept/send methods. It would be really helpful to plug such functionality into Boost.Thread.
int receive(/* some params */) {
// ReadFile() call and error handling
if(boost::this_thread::set_interruption_point(boost::bind(SetEvent, m_overlapped.hEvent)) {
GetOverlappedResult(m_pd, &m_overlapped, &transferredBytes, TRUE);
boost::this_thread::interruption_point();
} else {
throw boost::thread_interrupted();
}
// here we got our result and can proceed
}
Regards
Dimitrij
-- Computer Bild Tarifsieger! GMX FreeDSL - Telefonanschluss + DSL für nur 17,95 ¿/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a