File tree 1 file changed +7
-5
lines changed
1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change 6
6
7
7
#include < assert.h>
8
8
#include < boost/bind.hpp>
9
+ #include < boost/thread/reverse_lock.hpp>
9
10
#include < utility>
10
11
11
12
CScheduler::CScheduler () : nThreadsServicingQueue(0 ), stopRequested(false ), stopWhenEmpty(false )
@@ -65,11 +66,12 @@ void CScheduler::serviceQueue()
65
66
Function f = taskQueue.begin ()->second ;
66
67
taskQueue.erase (taskQueue.begin ());
67
68
68
- // Unlock before calling f, so it can reschedule itself or another task
69
- // without deadlocking:
70
- lock.unlock ();
71
- f ();
72
- lock.lock ();
69
+ {
70
+ // Unlock before calling f, so it can reschedule itself or another task
71
+ // without deadlocking:
72
+ boost::reverse_lock<boost::unique_lock<boost::mutex> > rlock (lock);
73
+ f ();
74
+ }
73
75
} catch (...) {
74
76
--nThreadsServicingQueue;
75
77
throw ;
You can’t perform that action at this time.
0 commit comments