WPILibC++  2018.4.1-20180921140244-1192-ge26e3b6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
Check.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_CHECK_H_
9 #define WPIUTIL_WPI_UV_CHECK_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 Check final : public HandleImpl<Check, uv_check_t> {
29  struct private_init {};
30 
31  public:
32  explicit Check(const private_init&) {}
33  ~Check() noexcept override = default;
34 
40  static std::shared_ptr<Check> Create(Loop& loop);
41 
47  static std::shared_ptr<Check> Create(const std::shared_ptr<Loop>& loop) {
48  return Create(*loop);
49  }
50 
54  void Start();
55 
59  void Stop() { Invoke(&uv_check_stop, GetRaw()); }
60 
65 };
66 
67 } // namespace uv
68 } // namespace wpi
69 
70 #endif // WPIUTIL_WPI_UV_CHECK_H_
uv_check_t * GetRaw() const noexcept
Get the underlying handle data structure.
Definition: Handle.h:261
Handle.
Definition: Handle.h:246
WPILib C++ utilities (wpiutil) namespace.
Definition: SmallString.h:21
Check handle.
Definition: Check.h:28
void Stop()
Stop the handle.
Definition: Check.h:59
void Start()
Start the handle.
static std::shared_ptr< Check > Create(const std::shared_ptr< Loop > &loop)
Create a check handle.
Definition: Check.h:47
Event loop.
Definition: Loop.h:37
sig::Signal check
Signal generated once per loop iteration after polling for I/O.
Definition: Check.h:64
SignalBase is an implementation of the observer pattern, through the use of an emitting object and sl...
Definition: Signal.h:495
static std::shared_ptr< Check > Create(Loop &loop)
Create a check handle.