Commit 62c7d215 authored by Joseph Mirabel's avatar Joseph Mirabel Committed by Joseph Mirabel

Fix deadlock

parent f189006d
......@@ -5,7 +5,6 @@
# include <boost/shared_ptr.hpp>
# include <boost/thread/mutex.hpp>
# include <boost/thread/condition_variable.hpp>
# include <dynamic-graph/entity.h>
# include <dynamic-graph/signal-time-dependent.h>
......@@ -106,7 +105,6 @@ namespace dynamicgraph
// synchronize with method reader
rmutex.lock();
frontIdx = backIdx = 0;
fullCondition.notify_all ();
rmutex.unlock();
wmutex.unlock();
}
......@@ -136,7 +134,6 @@ namespace dynamicgraph
size_type backIdx;
buffer_t buffer;
boost::mutex wmutex, rmutex;
boost::condition_variable fullCondition;
T last;
bool init;
......
......@@ -67,10 +67,10 @@ namespace dynamicgraph
{
// synchronize with method clear
boost::mutex::scoped_lock lock(wmutex);
boost::mutex dummy;
boost::unique_lock<boost::mutex> lock_dummy (dummy);
while (full()) {
fullCondition.wait (lock_dummy);
if (full()) {
rmutex.lock();
frontIdx = (frontIdx + 1) % N;
rmutex.unlock();
}
converter (buffer[backIdx], data);
// No need to synchronize with reader here because:
......@@ -99,7 +99,6 @@ namespace dynamicgraph
data = buffer[frontIdx];
frontIdx = (frontIdx + 1) % N;
last = data;
fullCondition.notify_all();
}
}
return data;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment