Suggestion for Boost.Thread

Hi, booster, I am using boost.thread in Windows with VC6, it's quite handy and useful. I found it's better if the library can add 2 additional methods. One is the typedef platform_dependent thread_id_type; thread_id_type id() const ; sometimes I want to know what thread is really in the log file. so I can write this: std::cout << thread().id() << std::endl; another one is a way to return the raw thread_handle. typedef platform_dependent thread_handle thread_handle handle() const ; by this, I can suspend, terminate the thread in Windows, or in Posix platform using #ifdef. For example; boost::thread t(...); #ifdef WINDOWS ::TerminateThread(t.handle()); #endif Is this doable? Thanks.

ycc wrote:
Hi, booster,
I am using boost.thread in Windows with VC6, it's quite handy and useful. I found it's better if the library can add 2 additional methods.
<snip>
another one is a way to return the raw thread_handle.
typedef platform_dependent thread_handle thread_handle handle() const ;
by this, I can suspend, terminate the thread in Windows, or in Posix platform using #ifdef. For example; boost::thread t(...); #ifdef WINDOWS ::TerminateThread(t.handle()); #endif
This is unsafe because, for example, the target thread may be holding a mutex which can then never be unlocked. Valid uses for thread suspension and termination are few and far between. Ben.

This is unsafe because, for example, the target thread may be holding a mutex which can then never be unlocked. Valid uses for thread suspension and termination are few and far between.
Ben.
Maybe I used a wrong example The TerminateThread is only a example to illustrate some additional platform-dependent request. Of course TerminateThread is evil, but sometimes we know it and use it. What I need is , we don't lost control for the thread, I stilll can call any raw api in rare case.
participants (2)
-
Ben Hutchings
-
ycc