diff options
Diffstat (limited to 'src/scheduler.cpp')
| -rw-r--r-- | src/scheduler.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/scheduler.cpp b/src/scheduler.cpp index d5bb588b7..184ddc28a 100644 --- a/src/scheduler.cpp +++ b/src/scheduler.cpp @@ -4,6 +4,8 @@ #include "scheduler.h" +#include "reverselock.h" + #include <assert.h> #include <boost/bind.hpp> #include <utility> @@ -65,11 +67,12 @@ void CScheduler::serviceQueue() Function f = taskQueue.begin()->second; taskQueue.erase(taskQueue.begin()); - // Unlock before calling f, so it can reschedule itself or another task - // without deadlocking: - lock.unlock(); - f(); - lock.lock(); + { + // Unlock before calling f, so it can reschedule itself or another task + // without deadlocking: + reverse_lock<boost::unique_lock<boost::mutex> > rlock(lock); + f(); + } } catch (...) { --nThreadsServicingQueue; throw; |