A WorkerThread executes its Delegate's DoWork method repeatedly on a dedicated thread at a set time interval.
More...
#include "util/thread/worker_thread.h"
|
| WorkerThread (double work_interval, Delegate *delegate) |
| Creates a new WorkerThread that is not yet running. More...
|
|
void | Start (double initial_work_delay) |
| Starts the worker thread. More...
|
|
void | Stop () |
| Stops the worker thread from running. More...
|
|
void | DoWorkNow () |
| Interrupts a work_interval to execute the work function immediately. This invokes Delegate::DoWork() on the thread, without waiting for the current work_interval to expire. After the delegate is invoked, the WorkerThread will start waiting for a new work_interval.
|
|
bool | is_running () const |
|
|
static constexpr double | kIndefiniteWait = Semaphore::kIndefiniteWait |
| A delay or interval argument that causes an indefinite wait.
|
|
|
class | internal::WorkerThreadImpl |
|
A WorkerThread executes its Delegate's DoWork method repeatedly on a dedicated thread at a set time interval.
◆ WorkerThread()
Creates a new WorkerThread that is not yet running.
- Parameters
-
[in] | work_interval | The time interval in seconds at which the delegate runs. The interval counts from the completion of Delegate::DoWork() to the next invocation. This can be kIndefiniteWait if work should only be done when DoWorkNow() is called. |
[in] | delegate | The work delegate to invoke every interval. |
◆ is_running()
bool crashpad::WorkerThread::is_running |
( |
| ) |
const |
|
inline |
- Returns
true
if the thread is running, false
if it is not.
◆ Start()
void crashpad::WorkerThread::Start |
( |
double |
initial_work_delay | ) |
|
Starts the worker thread.
This may not be called if the thread is_running().
- Parameters
-
[in] | initial_work_delay | The amount of time in seconds to wait before invoking the delegate for the first time. Pass 0 for no delay. This can be kIndefiniteWait if work should not be done until DoWorkNow() is called. |
◆ Stop()
void crashpad::WorkerThread::Stop |
( |
| ) |
|
Stops the worker thread from running.
This may only be called if the thread is_running().
If the work function is currently executing, this will not interrupt it. This method stops any future work from occurring. This method is safe to call from any thread with the exception of the worker thread itself, as this joins the thread.
The documentation for this class was generated from the following files:
- util/thread/worker_thread.h
- util/thread/worker_thread.cc