Class to wait for the asynchronous task finished.
More...
#include <ThreadPool.h>
|
| WaitGuard () |
| Constructor of WaitGuard.
|
|
| ~WaitGuard () |
| Destructor of WaitGuard.
|
|
void | release () |
| Call wait(), release the resource, and turn the valid state to invalid.
|
|
Error | wait () |
| Block the current thread until the asynchronous task finished.
|
|
Error | tryWait () |
| Query without blocking whether the asynchronous task finished.
|
|
Error | timedWait (Timeout tmout) |
| Block the current thread until the asynchronous task finished but only within the limited time.
|
|
bool | isValid () const |
| Return true if the validity state is valid.
|
|
Class to wait for the asynchronous task finished.
WaitGuard has a validity state, valid or invalid. After constuction, the state is invalid. The state becomes valid by ThreadPool::start(), ThreadPool::tryStart(), or ThreadPool::timedStart(). If the state is valid, the thread that owns this WaitGuard must wait() until the started asynchronous task finished and must release() the WaitGuard. After release(), the state becomes invalid.
WaitGuard can't be copied.
◆ WaitGuard()
OSWrapper::ThreadPool::WaitGuard::WaitGuard |
( |
| ) |
|
◆ ~WaitGuard()
OSWrapper::ThreadPool::WaitGuard::~WaitGuard |
( |
| ) |
|
◆ isValid()
bool OSWrapper::ThreadPool::WaitGuard::isValid |
( |
| ) |
const |
Return true if the validity state is valid.
- Return values
-
true | The state is valid |
false | The state is invalid |
◆ release()
void OSWrapper::ThreadPool::WaitGuard::release |
( |
| ) |
|
Call wait(), release the resource, and turn the valid state to invalid.
- Postcondition
- isValid() == false
- Note
- If the state is invalid, this method does nothing.
◆ timedWait()
Error OSWrapper::ThreadPool::WaitGuard::timedWait |
( |
Timeout |
tmout | ) |
|
Block the current thread until the asynchronous task finished but only within the limited time.
- Parameters
-
- Return values
-
OK | Success. The asynchronous task has finished |
TimedOut | The limited time was elapsed |
CalledByNonThread | Called from non thread context (interrupt handler, timer, etc) |
- Note
- If the state is invalid, this method returns OK immediately.
-
If
tmout
is Timeout::POLLING then this method queries the state without blocking.
-
If
tmout
is Timeout::FOREVER then this method waits forever until the condition is satisfied.
◆ tryWait()
Error OSWrapper::ThreadPool::WaitGuard::tryWait |
( |
| ) |
|
Query without blocking whether the asynchronous task finished.
- Return values
-
OK | The asynchronous task has already finished |
TimedOut | The asynchronous task has not finished yet |
- Note
- If the state is invalid, this method returns OK immediately.
-
Same as timedWait(Timeout::POLLING)
◆ wait()
Error OSWrapper::ThreadPool::WaitGuard::wait |
( |
| ) |
|
Block the current thread until the asynchronous task finished.
- Return values
-
OK | Success. The asynchronous task has finished |
CalledByNonThread | Called from non thread context (interrupt handler, timer, etc) |
- Note
- If the state is invalid, this method returns OK immediately.
-
Same as timedWait(Timeout::FOREVER)
The documentation for this class was generated from the following files: