mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 14:35:52 +00:00
Add bool return to stopThread
This commit is contained in:
@@ -171,8 +171,10 @@ bool Thread::waitForThreadToExit (const int timeOutMilliseconds) const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thread::stopThread (const int timeOutMilliseconds)
|
bool Thread::stopThread (const int timeOutMilliseconds)
|
||||||
{
|
{
|
||||||
|
bool cleanExit = true;
|
||||||
|
|
||||||
// agh! You can't stop the thread that's calling this method! How on earth
|
// agh! You can't stop the thread that's calling this method! How on earth
|
||||||
// would that work??
|
// would that work??
|
||||||
bassert (getCurrentThreadId() != getThreadId());
|
bassert (getCurrentThreadId() != getThreadId());
|
||||||
@@ -185,21 +187,30 @@ void Thread::stopThread (const int timeOutMilliseconds)
|
|||||||
notify();
|
notify();
|
||||||
|
|
||||||
if (timeOutMilliseconds != 0)
|
if (timeOutMilliseconds != 0)
|
||||||
waitForThreadToExit (timeOutMilliseconds);
|
{
|
||||||
|
cleanExit = waitForThreadToExit (timeOutMilliseconds);
|
||||||
|
}
|
||||||
|
|
||||||
if (isThreadRunning())
|
if (isThreadRunning())
|
||||||
{
|
{
|
||||||
|
bassert (! cleanExit);
|
||||||
|
|
||||||
// very bad karma if this point is reached, as there are bound to be
|
// very bad karma if this point is reached, as there are bound to be
|
||||||
// locks and events left in silly states when a thread is killed by force..
|
// locks and events left in silly states when a thread is killed by force..
|
||||||
bassertfalse;
|
|
||||||
Logger::writeToLog ("!! killing thread by force !!");
|
|
||||||
|
|
||||||
killThread();
|
killThread();
|
||||||
|
|
||||||
threadHandle = nullptr;
|
threadHandle = nullptr;
|
||||||
threadId = 0;
|
threadId = 0;
|
||||||
|
|
||||||
|
cleanExit = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cleanExit = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return cleanExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|||||||
@@ -109,8 +109,10 @@ public:
|
|||||||
thread to finish before killing it by force. A negative
|
thread to finish before killing it by force. A negative
|
||||||
value in here will wait forever.
|
value in here will wait forever.
|
||||||
@see signalThreadShouldExit, threadShouldExit, waitForThreadToExit, isThreadRunning
|
@see signalThreadShouldExit, threadShouldExit, waitForThreadToExit, isThreadRunning
|
||||||
|
|
||||||
|
@returns true if the thread exits, or false if the timeout expires first.
|
||||||
*/
|
*/
|
||||||
void stopThread (int timeOutMilliseconds = -1);
|
bool stopThread (int timeOutMilliseconds = -1);
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
/** Returns true if the thread is currently active */
|
/** Returns true if the thread is currently active */
|
||||||
|
|||||||
Reference in New Issue
Block a user