I have a Wrapper class similar to something shown below. It wraps a std::thread instance and provides additional functionality on top of it.
class ToShare
{
public:
void test();
};
thread_local ToShare this_thread_share;
class WrapperThread
{
std::thread _thread;
public:
template<typename FunctionType>
WrapperThread(FunctionType f)
{
_thread=std::thread([f]{
f();
});
}
};
Now I want this WrapperClass instance to able to access the same this_thread_share object that the thread that it created accesses. How do I do this?
In other words how do I share a thread local value with the wrapper class instance?
Aucun commentaire:
Enregistrer un commentaire