WPILibC++  2019.3.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
wpi::EventLoopRunner Class Reference

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::LoopGetLoop ()
 Get the loop. More...
 

Detailed Description

Executes an event loop on a separate thread.

Member Function Documentation

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).

Parameters
funcfunction 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.

Parameters
funcfunction 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.

Returns
The loop
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.


The documentation for this class was generated from the following file: