WPILibC++
2020.3.2
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
22
class
EventLoopRunner
{
23
public
:
24
using
LoopFunc = std::function<void(
uv::Loop
&)>;
25
26
EventLoopRunner
();
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;
60
SafeThreadOwner<Thread>
m_owner;
61
};
62
63
}
// namespace wpi
64
65
#endif // WPIUTIL_WPI_EVENTLOOPRUNNER_H_
wpi::EventLoopRunner
Executes an event loop on a separate thread.
Definition:
EventLoopRunner.h:22
wpi::SafeThreadOwner< Thread >
wpi
WPILib C++ utilities (wpiutil) namespace.
Definition:
EventLoopRunner.h:17
wpi::EventLoopRunner::Stop
void Stop()
Stop the loop.
wpi::uv::Loop
Event loop.
Definition:
Loop.h:39
wpi::EventLoopRunner::ExecAsync
void ExecAsync(LoopFunc func)
Run a function asynchronously (once) on the loop.
wpi::EventLoopRunner::ExecSync
void ExecSync(LoopFunc func)
Run a function synchronously (once) on the loop.
wpi::EventLoopRunner::GetLoop
std::shared_ptr< uv::Loop > GetLoop()
Get the loop.
wpiutil
src
main
native
include
wpi
EventLoopRunner.h
Generated on Fri Feb 21 2020 08:50:36 for WPILibC++ by
1.8.16