Boost Thread Specific Storage Question (boost/thread/tss.hpp)

Posted by Hassan Syed on Stack Overflow See other posts from Stack Overflow or by Hassan Syed
Published on 2010-04-12T15:56:06Z Indexed on 2010/04/13 4:13 UTC
Read the original article Hit count: 472

The boost threading library has an abstraction for thread specific (local) storage. I have skimmed over the source code and it seems that the TSS functionality can be used in an application with any existing thread regardless of weather it was created from boost::thread --i.e., this implies that certain callbacks are registered with the kernel to hook in a callback function that may call the destructor of any TSS objects when the thread or process is going out of scope. I have found these callbacks.

I need to cache HMAC_CTX's from OpenSSL inside the worker threads of various web-servers (see this, detailed, question for what I am trying to do), and as such I do not controll the life-time of the thread -- the web-server does. Therefore I will use the TSS functionality on threads not created by boost::thread.

I just wanted to validate my assumptions before I started implementing the caching logic, are there any flaws in my logic ?

© Stack Overflow or respective owner

Related posts about boost-thread

Related posts about c++