#include <wpinet/WorkerThread.h>
◆ AfterWorkFunction
template<typename R , typename... T>
◆ WorkFunction
template<typename R , typename... T>
◆ WorkerThread()
template<typename R , typename... T>
◆ GetHandle()
template<typename R , typename... T>
Get the handle used by QueueWorkThen() to run afterWork.
This handle is set by SetLoop(). Calling Close() on this handle is the same as calling UnsetLoop().
- Returns
- The handle (if nullptr, no handle is set)
◆ QueueWork()
template<typename R , typename... T>
template<typename... U>
Wakeup the worker thread, call the work function, and return a future for the result.
It’s safe to call this function from any thread. The work function will be called on the worker thread.
The future will return a default-constructed result if this class is destroyed while waiting for a result.
- Parameters
-
work | Work function (called on worker thread) |
u | Arguments to work function |
◆ QueueWorkThen()
template<typename R , typename... T>
template<typename... U>
Wakeup the worker thread, call the work function, and call the afterWork function with the result on the loop set by SetLoop().
It’s safe to call this function from any thread. The work function will be called on the worker thread, and the afterWork function will be called on the loop thread.
SetLoop() must be called prior to calling this function for afterWork to be called.
- Parameters
-
work | Work function (called on worker thread) |
afterWork | After work function (called on loop thread) |
u | Arguments to work function |
◆ SetLoop() [1/2]
template<typename R , typename... T>
Set the loop.
This must be called from the loop thread. Subsequent calls to QueueWorkThen will run afterWork on the provided loop (via an async handle).
- Parameters
-
loop | the loop to use for running afterWork routines |
◆ SetLoop() [2/2]
template<typename R , typename... T>
Set the loop.
This must be called from the loop thread. Subsequent calls to QueueWorkThen will run afterWork on the provided loop (via an async handle).
- Parameters
-
loop | the loop to use for running afterWork routines |
◆ UnsetLoop()
template<typename R , typename... T>
Unset the loop.
This must be called from the loop thread. Subsequent calls to QueueWorkThen will no longer run afterWork.
The documentation for this class was generated from the following file: