i have bunch of question regarding to boost thread ?
- How to initialize the boost thread ID with the thread constructor?
- Why the thread id becomes invalid after called join() function ?
- As usual, a class member function is copy to thread internal storage in order to execute the member function but i found out that someone just encapsulates the boost thread in a class.
What is the purposes for this ?
On the other hands, do we allow to inherit the boost thread ?
Please help.
Thanks.
boost::threadobject by calling it’sget_id()member function:You can get the ID of the current thread by calling
boost::this_thread::get_id().Thread ID values remain valid after a thread exits, unlike the thread IDs for some OS thread libraries.
If you pass in the address of a member function, and the address of an object then you can run a member function on that object on a new thread. You can therefore start threads in a member function, and pass
thisas the object pointer. This allows the new thread to share data via the data members of the class instance.You can derive from
boost::threadbut it wouldn’t really get you anywhere as there are no virtual functions.