I am a newbie to this forum, and this is actually my first post. I am looking for a way to get the object of the currently running thread in boost. To make this short, consider a case in which one wants to implement a semaphor or a condition variable. That is:
Semaphor:
Queue<boost::thread> queue;
void wait()
{
if( some condition)
{
queue.enqueue( "current thread object" ); (1)
boost::this_thread ( // context switch ) (2)
}
}
void signal()
{
boost::thread myThread = queue.dequeue();
myThread.run(); (3)
}
The problem that I have is with lines (1), (2), and (3) in the snippet.
(1) : how can I pass the thread object of the currently running thread?
(2): how can I perform the context switching without using boost::condition_variable ? (eg. sleep(for ever) )
(3): how can I re-run the thread?
This is easy in Java, but unfortunately I wasn't able to find the solution in boost.