
----- Original Message -----
From: "OvermindDL1"
On Fri, Jan 29, 2010 at 11:22 PM, Hua Su
wrote: On Sat, Jan 30, 2010 at 7:37 AM, Anthony Williams
wrote: Hua Su
writes: Is it OK to use both pthread and boost.thread in the same program under linux?
Yes.
1. use pthread api to create/join/detach/cancel threads but use boost.thread's mutex/condition_variable etc. to do thread synchronization, and this_thread/ sleep/get_id/thread_local_storage etc..
That's fine.
Another reply of this topic by OvermindDL1 said "things like this_thread will not work on non Boost.Threads". Could you give any explanation about this?
I may be wrong, but I could have *sworn* that at one point in time if I used native windows threads, then some of the Boost.Threads functionality just kind of choked. Am I wrong? If so, I would love to know. :)
Hi, the functions at the this_thread namespace can be used in native threads without any know issue. You are not alone to think that and an example on the documentation should be added to show the possibility. This was a requirement as libraries don't know which kind of threads calls its functions. In general all the combinations should work, as pointed by Anthony. The usage of Boost.Thread resources by other parts is available using the native_handle() API (note that not every resource has the native_handle() function). The oposite is not supported except by the current thread., i.e. if a part of the program gives the reference of a pthread resource, there is no mean to retrieve the Boost.Thread resource. The application needs in this case to map the resources if the need appear in his application. The use cases presented should not be risky as there is no need to exchange the resources if I have understood. HTH, Vicente