WPILibC++  2019.1.1-beta-1-5-g9a1af13
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
Prepare.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_PREPARE_H_
9 #define WPIUTIL_WPI_UV_PREPARE_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 
28 class Prepare final : public HandleImpl<Prepare, uv_prepare_t> {
29  struct private_init {};
30 
31  public:
32  explicit Prepare(const private_init&) {}
33  ~Prepare() noexcept override = default;
34 
40  static std::shared_ptr<Prepare> Create(Loop& loop);
41 
47  static std::shared_ptr<Prepare> Create(const std::shared_ptr<Loop>& loop) {
48  return Create(*loop);
49  }
50 
54  void Start();
55 
59  void Stop() { Invoke(&uv_prepare_stop, GetRaw()); }
60 
65 };
66 
67 } // namespace uv
68 } // namespace wpi
69 
70 #endif // WPIUTIL_WPI_UV_PREPARE_H_
uv_prepare_t * GetRaw() const noexcept
Get the underlying handle data structure.
Definition: Handle.h:264
Handle.
Definition: Handle.h:249
static std::shared_ptr< Prepare > Create(Loop &loop)
Create a prepare handle.
WPILib C++ utilities (wpiutil) namespace.
Definition: SmallString.h:21
static std::shared_ptr< Prepare > Create(const std::shared_ptr< Loop > &loop)
Create a prepare handle.
Definition: Prepare.h:47
void Stop()
Stop the handle.
Definition: Prepare.h:59
Prepare handle.
Definition: Prepare.h:28
void Start()
Start the handle.
Event loop.
Definition: Loop.h:39
sig::Signal prepare
Signal generated once per loop iteration prior to polling for I/O.
Definition: Prepare.h:64
SignalBase is an implementation of the observer pattern, through the use of an emitting object and sl...
Definition: Signal.h:495