0
我遇到的问题是在代码段中的行(1),(2)和(3)。如何在boost中找到当前正在运行的线程?
- 如何传递当前正在运行的线程的线程对象?
- 如何在不使用boost :: condition_variable的情况下执行上下文切换? (例如:
sleep(for ever)
) - 如何重新运行线程?
1 void wait()
2 {
3 if(some condition)
4 {
5 queue.enqueue("current thread object"); (1)
6 boost::this_thread (// context switch) (2)
7 }
8 }
9
10 void signal()
11 {
12 boost::thread myThread = queue.dequeue();
13 myThread.run(); (3)
14 }