diff --git a/Subtrees/beast/modules/beast_core/thread/beast_DeadlineTimer.cpp b/Subtrees/beast/modules/beast_core/thread/beast_DeadlineTimer.cpp index 4872a76561..e5d644a685 100644 --- a/Subtrees/beast/modules/beast_core/thread/beast_DeadlineTimer.cpp +++ b/Subtrees/beast/modules/beast_core/thread/beast_DeadlineTimer.cpp @@ -170,7 +170,6 @@ public: // is extremely short, or if a listener wastes too much time in // their callback. } - } } } diff --git a/Subtrees/beast/modules/beast_core/thread/beast_InterruptibleThread.cpp b/Subtrees/beast/modules/beast_core/thread/beast_InterruptibleThread.cpp index e732b3cba3..f0d1f07062 100644 --- a/Subtrees/beast/modules/beast_core/thread/beast_InterruptibleThread.cpp +++ b/Subtrees/beast/modules/beast_core/thread/beast_InterruptibleThread.cpp @@ -66,7 +66,7 @@ void InterruptibleThread::join () m_thread.stopThread (-1); } -bool InterruptibleThread::wait (int milliSeconds) +void InterruptibleThread::wait () { // Can only be called from the corresponding thread of execution. // @@ -87,8 +87,7 @@ bool InterruptibleThread::wait (int milliSeconds) interrupted = true; break; } - else if (m_state.tryChangeState (stateRun, stateWait) || - m_state.tryChangeState (stateReturn, stateWait)) + else if (m_state.tryChangeState (stateRun, stateWait)) { // Transitioned to wait. Caller must wait now. // @@ -101,33 +100,12 @@ bool InterruptibleThread::wait (int milliSeconds) { bassert (m_state == stateWait); - interrupted = m_thread.wait (milliSeconds); + m_thread.wait (); - if (! interrupted) - { - // The wait timed out - // - if (m_state.tryChangeState (stateWait, stateRun)) - { - interrupted = false; - } - else - { - bassert (m_state == stateInterrupt); - - interrupted = true; - } - } - else - { - // The event became signalled, which can only - // happen via m_event.notify() in interrupt() - // - bassert (m_state == stateRun); - } + // The event became signalled. + // + bassert (m_state == stateRun || m_state == stateInterrupt); } - - return interrupted; } void InterruptibleThread::interrupt () @@ -137,8 +115,7 @@ void InterruptibleThread::interrupt () int const state = m_state; if (state == stateInterrupt || - state == stateReturn || - m_state.tryChangeState (stateRun, stateInterrupt)) + m_state.tryChangeState (stateRun, stateInterrupt)) { // Thread will see this at next interruption point. // @@ -158,19 +135,8 @@ bool InterruptibleThread::interruptionPoint () // bassert (isTheCurrentThread ()); - if (m_state == stateWait) - { - // It is impossible for this function to be called while in the wait state. - // - Throw (Error ().fail (__FILE__, __LINE__)); - } - else if (m_state == stateReturn) - { - // If this goes off it means the thread called the - // interruption a second time after already getting interrupted. - // - Throw (Error ().fail (__FILE__, __LINE__)); - } + // It is impossible for this function to be called while in the wait state. + check_precondition (m_state != stateWait); bool const interrupted = m_state.tryChangeState (stateInterrupt, stateRun); diff --git a/Subtrees/beast/modules/beast_core/thread/beast_InterruptibleThread.h b/Subtrees/beast/modules/beast_core/thread/beast_InterruptibleThread.h index bf78b45f64..658d486543 100644 --- a/Subtrees/beast/modules/beast_core/thread/beast_InterruptibleThread.h +++ b/Subtrees/beast/modules/beast_core/thread/beast_InterruptibleThread.h @@ -71,20 +71,11 @@ public: */ void join (); - /** Wait for interrupt or timeout. - - This call blocks until the thread is interrupted, or until the timeout - expires if milliSeconds is non-negative. - + /** Wait for interrupt. + This call blocks until the thread is interrupted. May only be called by the thread of execution. - - @param milliSeconds The amount of time to wait. Negative values mean - no timeout. - - @return `true` if the interrupt occurred, or `false` if the - timeout expired. */ - bool wait (int milliSeconds = -1); + void wait (); /** Interrupt the thread of execution. @@ -159,7 +150,6 @@ private: { stateRun, stateInterrupt, - stateReturn, stateWait };