Access to underlying system thread

Hi, I like using boost threads, but I'm currently working on a project where I need to access the private handle to the underlying system thread (in the cases I'm concerned about, the pthread_t). This is so that I can take advantage of platform-specific functionality, such as setting CPU affinity and (more generally) calling into other libraries that expect a pthread_t. Is there any way to do get this handle? Thanks! -- Yang Zhang http://www.mit.edu/~y_z/

Yang Zhang wrote:
Hi, I like using boost threads, but I'm currently working on a project where I need to access the private handle to the underlying system thread (in the cases I'm concerned about, the pthread_t). This is so that I can take advantage of platform-specific functionality, such as setting CPU affinity and (more generally) calling into other libraries that expect a pthread_t. Is there any way to do get this handle?
Thanks!
class thread { public: ... typedef platform-specific-type native_handle_type; native_handle_type native_handle(); ... }; I haven't used it myself though. --Johan

Ah, new in 1.35! Awesome, thanks. Johan Råde wrote:
Yang Zhang wrote:
Hi, I like using boost threads, but I'm currently working on a project where I need to access the private handle to the underlying system thread (in the cases I'm concerned about, the pthread_t). This is so that I can take advantage of platform-specific functionality, such as setting CPU affinity and (more generally) calling into other libraries that expect a pthread_t. Is there any way to do get this handle?
Thanks!
class thread { public: ... typedef platform-specific-type native_handle_type; native_handle_type native_handle(); ... };
I haven't used it myself though.
--Johan
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Johan Råde wrote:
Yang Zhang wrote:
Hi, I like using boost threads, but I'm currently working on a project where I need to access the private handle to the underlying system thread (in the cases I'm concerned about, the pthread_t). This is so that I can take advantage of platform-specific functionality, such as setting CPU affinity and (more generally) calling into other libraries that expect a pthread_t. Is there any way to do get this handle?
Thanks!
class thread { public: ... typedef platform-specific-type native_handle_type; native_handle_type native_handle(); ... };
I haven't used it myself though.
--Johan
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Hmm. Looking at the source, this doesn't actually seem to be in there...at least not in the latest release (1.35).

Yang Zhang
Johan Råde wrote:
Yang Zhang wrote:
Hi, I like using boost threads, but I'm currently working on a project where I need to access the private handle to the underlying system thread (in the cases I'm concerned about, the pthread_t). This is so that I can take advantage of platform-specific functionality, such as setting CPU affinity and (more generally) calling into other libraries that expect a pthread_t. Is there any way to do get this handle?
Thanks!
class thread { public: ... typedef platform-specific-type native_handle_type; native_handle_type native_handle(); ... };
Hmm. Looking at the source, this doesn't actually seem to be in there...at least not in the latest release (1.35).
It's there for Win32 and not for pthreads. I'll add it for pthreads on trunk. Anthony -- Anthony Williams | Just Software Solutions Ltd Custom Software Development | http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL

Anthony Williams wrote:
Yang Zhang
writes: Yang Zhang wrote:
Hi, I like using boost threads, but I'm currently working on a project where I need to access the private handle to the underlying system thread (in the cases I'm concerned about, the pthread_t). This is so that I can take advantage of platform-specific functionality, such as setting CPU affinity and (more generally) calling into other libraries that expect a pthread_t. Is there any way to do get this handle?
Thanks!
class thread { public: ... typedef platform-specific-type native_handle_type; native_handle_type native_handle(); ... }; Hmm. Looking at the source, this doesn't actually seem to be in
Johan Råde wrote: there...at least not in the latest release (1.35).
It's there for Win32 and not for pthreads. I'll add it for pthreads on trunk.
Anthony
I see. While you're at it, would you mind also adding it uniformly to all the other threading primitives (mutex, etc.)? Thanks! -- Yang Zhang http://www.mit.edu/~y_z/

Yang Zhang
Anthony Williams wrote:
Yang Zhang
writes: Yang Zhang wrote:
Hi, I like using boost threads, but I'm currently working on a project where I need to access the private handle to the underlying system thread (in the cases I'm concerned about, the pthread_t). This is so that I can take advantage of platform-specific functionality, such as setting CPU affinity and (more generally) calling into other libraries that expect a pthread_t. Is there any way to do get this handle?
Thanks!
class thread { public: ... typedef platform-specific-type native_handle_type; native_handle_type native_handle(); ... }; Hmm. Looking at the source, this doesn't actually seem to be in
Johan Råde wrote: there...at least not in the latest release (1.35).
It's there for Win32 and not for pthreads. I'll add it for pthreads on trunk.
Anthony
I see.
While you're at it, would you mind also adding it uniformly to all the other threading primitives (mutex, etc.)?
There isn't always a valid mapping (e.g. condition_variable_any, timed_mutex), but I intend to add it where possible. Anthony -- Anthony Williams | Just Software Solutions Ltd Custom Software Development | http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL

Yang Zhang wrote:
class thread { public: ... typedef platform-specific-type native_handle_type; native_handle_type native_handle(); ... };
Hmm. Looking at the source, this doesn't actually seem to be in there...at least not in the latest release (1.35).
It seems that native_handle() is defined in thread/win32/thread.hpp but not in thread/pthread/thread.hpp. --Johan
participants (3)
-
Anthony Williams
-
Johan Råde
-
Yang Zhang