WPILibC++
2019.1.1-beta-3-2-g4159660
|
Executes an event loop on a separate thread. More...
#include <EventLoopRunner.h>
Public Types | |
using | LoopFunc = std::function< void(uv::Loop &)> |
Public Member Functions | |
void | Stop () |
Stop the loop. More... | |
void | ExecAsync (LoopFunc func) |
Run a function asynchronously (once) on the loop. More... | |
void | ExecSync (LoopFunc func) |
Run a function synchronously (once) on the loop. More... | |
std::shared_ptr< uv::Loop > | GetLoop () |
Get the loop. More... | |
Executes an event loop on a separate thread.
void wpi::EventLoopRunner::ExecAsync | ( | LoopFunc | func | ) |
Run a function asynchronously (once) on the loop.
This is safe to call from any thread, but is NOT safe to call from the provided function (it will deadlock).
func | function to execute on the loop |
void wpi::EventLoopRunner::ExecSync | ( | LoopFunc | func | ) |
Run a function synchronously (once) on the loop.
This is safe to call from any thread, but is NOT safe to call from the provided function (it will deadlock). This does not return until the function finishes executing.
func | function to execute on the loop |
std::shared_ptr<uv::Loop> wpi::EventLoopRunner::GetLoop | ( | ) |
Get the loop.
If the loop thread is not running, returns nullptr.
void wpi::EventLoopRunner::Stop | ( | ) |
Stop the loop.
Once the loop is stopped it cannot be restarted. This function does not return until the loop has exited.