WPILibC++  2018.4.1-20180920010257-1187-gd2a5aaa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
EventLoopRunner.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2018 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #ifndef WPIUTIL_WPI_EVENTLOOPRUNNER_H_
9 #define WPIUTIL_WPI_EVENTLOOPRUNNER_H_
10 
11 #include <functional>
12 
13 #include "wpi/SafeThread.h"
14 #include "wpi/uv/Loop.h"
15 
16 namespace wpi {
17 
22  public:
23  using LoopFunc = std::function<void(wpi::uv::Loop&)>;
24 
26  virtual ~EventLoopRunner();
27 
34  void ExecAsync(LoopFunc func);
35 
43  void ExecSync(LoopFunc func);
44 
45  private:
46  class Thread;
48 };
49 
50 } // namespace wpi
51 
52 #endif // WPIUTIL_WPI_EVENTLOOPRUNNER_H_
void ExecAsync(LoopFunc func)
Run a function asynchronously (once) on the loop.
WPILib C++ utilities (wpiutil) namespace.
Definition: SmallString.h:21
Executes an event loop on a separate thread.
Definition: EventLoopRunner.h:21
void ExecSync(LoopFunc func)
Run a function synchronously (once) on the loop.