I am new to boost threading (came from Win32 threading, which has probably ruined me).
So I'm trying to make a more "RAII" way to check that the working loop should still be going. So I made this simple function:
template<typenameT>
T safe_read(const T& t,boost::mutex& mutex)
{
boost::interprocess::scoped_lock lock(mutex);
return t;
}
Is there a boost equivalent to this, since it seems like I'd use this all the time? Also it this an acceptable call?
The idea is to be able to safely do this without using a weirder lock:
while(!safe_read(this->is_killing_,this->is_killing_mutex_))
{
DoWork();
}