WPILibC++  2019.4.1-1-g12ab035
 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 #include <memory>
13 
14 #include "wpi/SafeThread.h"
15 #include "wpi/uv/Loop.h"
16 
17 namespace wpi {
18 
23  public:
24  using LoopFunc = std::function<void(uv::Loop&)>;
25 
27  virtual ~EventLoopRunner();
28 
33  void Stop();
34 
41  void ExecAsync(LoopFunc func);
42 
50  void ExecSync(LoopFunc func);
51 
56  std::shared_ptr<uv::Loop> GetLoop();
57 
58  private:
59  class Thread;
61 };
62 
63 } // namespace wpi
64 
65 #endif // WPIUTIL_WPI_EVENTLOOPRUNNER_H_
void ExecAsync(LoopFunc func)
Run a function asynchronously (once) on the loop.
void Stop()
Stop the loop.
WPILib C++ utilities (wpiutil) namespace.
Definition: SmallString.h:21
std::shared_ptr< uv::Loop > GetLoop()
Get the loop.
Executes an event loop on a separate thread.
Definition: EventLoopRunner.h:22
void ExecSync(LoopFunc func)
Run a function synchronously (once) on the loop.