mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-03 09:25:51 +00:00
Fix DeadlineTimer for InterruptibleThread::wait timeout
This commit is contained in:
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
class DeadlineTimer::Manager
|
class DeadlineTimer::Manager
|
||||||
: public SharedSingleton <DeadlineTimer::Manager>
|
: public SharedSingleton <DeadlineTimer::Manager>
|
||||||
, public InterruptibleThread::EntryPoint
|
, protected Thread
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef CriticalSection LockType;
|
typedef CriticalSection LockType;
|
||||||
@@ -28,18 +28,16 @@ private:
|
|||||||
public:
|
public:
|
||||||
Manager ()
|
Manager ()
|
||||||
: SharedSingleton <Manager> (SingletonLifetime::persistAfterCreation)
|
: SharedSingleton <Manager> (SingletonLifetime::persistAfterCreation)
|
||||||
, m_shouldStop (false)
|
, Thread ("DeadlineTimer::Manager")
|
||||||
, m_thread ("DeadlineTimer::Manager")
|
|
||||||
{
|
{
|
||||||
m_thread.start (this);
|
startThread ();
|
||||||
}
|
}
|
||||||
|
|
||||||
~Manager ()
|
~Manager ()
|
||||||
{
|
{
|
||||||
m_shouldStop = true;
|
signalThreadShouldExit ();
|
||||||
|
notify ();
|
||||||
m_thread.interrupt ();
|
waitForThreadToExit ();
|
||||||
|
|
||||||
bassert (m_items.empty ());
|
bassert (m_items.empty ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +63,7 @@ public:
|
|||||||
insertSorted (timer);
|
insertSorted (timer);
|
||||||
timer.m_isActive = true;
|
timer.m_isActive = true;
|
||||||
|
|
||||||
m_thread.interrupt ();
|
notify ();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Okay to call this on an inactive timer.
|
// Okay to call this on an inactive timer.
|
||||||
@@ -81,13 +79,13 @@ public:
|
|||||||
|
|
||||||
timer.m_isActive = false;
|
timer.m_isActive = false;
|
||||||
|
|
||||||
m_thread.interrupt ();
|
notify ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void threadRun ()
|
void run ()
|
||||||
{
|
{
|
||||||
while (! m_shouldStop)
|
while (! threadShouldExit ())
|
||||||
{
|
{
|
||||||
Time const currentTime = Time::getCurrentTime ();
|
Time const currentTime = Time::getCurrentTime ();
|
||||||
|
|
||||||
@@ -158,13 +156,13 @@ public:
|
|||||||
{
|
{
|
||||||
// Wait until interrupt or next timer.
|
// Wait until interrupt or next timer.
|
||||||
//
|
//
|
||||||
m_thread.wait (static_cast <int> (seconds * 1000 + 0.5));
|
wait (static_cast <int> (seconds * 1000 + 0.5));
|
||||||
}
|
}
|
||||||
else if (seconds == 0)
|
else if (seconds == 0)
|
||||||
{
|
{
|
||||||
// Wait until interrupt
|
// Wait until interrupt
|
||||||
//
|
//
|
||||||
m_thread.wait ();
|
wait ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -172,6 +170,7 @@ public:
|
|||||||
// is extremely short, or if a listener wastes too much time in
|
// is extremely short, or if a listener wastes too much time in
|
||||||
// their callback.
|
// their callback.
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,8 +211,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
CriticalSection m_mutex;
|
CriticalSection m_mutex;
|
||||||
bool volatile m_shouldStop;
|
|
||||||
InterruptibleThread m_thread;
|
|
||||||
Items m_items;
|
Items m_items;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user