WPILibC++  2018.4.1-20180928014753-1210-gac7dfa5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
Idle.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_UV_IDLE_H_
9 #define WPIUTIL_WPI_UV_IDLE_H_
10 
11 #include <uv.h>
12 
13 #include <memory>
14 
15 #include "wpi/Signal.h"
16 #include "wpi/uv/Handle.h"
17 
18 namespace wpi {
19 namespace uv {
20 
21 class Loop;
22 
37 class Idle final : public HandleImpl<Idle, uv_idle_t> {
38  struct private_init {};
39 
40  public:
41  explicit Idle(const private_init&) {}
42  ~Idle() noexcept override = default;
43 
49  static std::shared_ptr<Idle> Create(Loop& loop);
50 
56  static std::shared_ptr<Idle> Create(const std::shared_ptr<Loop>& loop) {
57  return Create(*loop);
58  }
59 
63  void Start();
64 
68  void Stop() { Invoke(&uv_idle_stop, GetRaw()); }
69 
74 };
75 
76 } // namespace uv
77 } // namespace wpi
78 
79 #endif // WPIUTIL_WPI_UV_IDLE_H_
uv_idle_t * GetRaw() const noexcept
Get the underlying handle data structure.
Definition: Handle.h:261
Handle.
Definition: Handle.h:246
static std::shared_ptr< Idle > Create(Loop &loop)
Create an idle handle.
WPILib C++ utilities (wpiutil) namespace.
Definition: SmallString.h:21
static std::shared_ptr< Idle > Create(const std::shared_ptr< Loop > &loop)
Create an idle handle.
Definition: Idle.h:56
Idle handle.
Definition: Idle.h:37
sig::Signal idle
Signal generated once per loop iteration prior to Prepare signals.
Definition: Idle.h:73
Event loop.
Definition: Loop.h:37
void Start()
Start the handle.
SignalBase is an implementation of the observer pattern, through the use of an emitting object and sl...
Definition: Signal.h:495
void Stop()
Stop the handle.
Definition: Idle.h:68