WPILibC++ 2023.4.3
Check.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#ifndef WPINET_UV_CHECK_H_
6#define WPINET_UV_CHECK_H_
7
8#include <uv.h>
9
10#include <memory>
11
12#include <wpi/Signal.h>
13
14#include "wpinet/uv/Handle.h"
15
16namespace wpi::uv {
17
18class Loop;
19
20/**
21 * Check handle.
22 * Check handles will generate a signal once per loop iteration, right
23 * after polling for I/O.
24 */
25class Check final : public HandleImpl<Check, uv_check_t> {
26 struct private_init {};
27
28 public:
29 explicit Check(const private_init&) {}
30 ~Check() noexcept override = default;
31
32 /**
33 * Create a check handle.
34 *
35 * @param loop Loop object where this handle runs.
36 */
37 static std::shared_ptr<Check> Create(Loop& loop);
38
39 /**
40 * Create a check handle.
41 *
42 * @param loop Loop object where this handle runs.
43 */
44 static std::shared_ptr<Check> Create(const std::shared_ptr<Loop>& loop) {
45 return Create(*loop);
46 }
47
48 /**
49 * Start the handle.
50 */
51 void Start();
52
53 /**
54 * Stop the handle. The signal will no longer be generated.
55 */
57
58 /**
59 * Signal generated once per loop iteration after polling for I/O.
60 */
62};
63
64} // namespace wpi::uv
65
66#endif // WPINET_UV_CHECK_H_
SignalBase is an implementation of the observer pattern, through the use of an emitting object and sl...
Definition: Signal.h:495
Check handle.
Definition: Check.h:25
void Start()
Start the handle.
void Stop()
Stop the handle.
Definition: Check.h:56
~Check() noexcept override=default
sig::Signal check
Signal generated once per loop iteration after polling for I/O.
Definition: Check.h:61
Check(const private_init &)
Definition: Check.h:29
static std::shared_ptr< Check > Create(Loop &loop)
Create a check handle.
bool Invoke(F &&f, Args &&... args) const
Definition: Handle.h:251
Handle.
Definition: Handle.h:273
uv_check_t * GetRaw() const noexcept
Get the underlying handle data structure.
Definition: Handle.h:288
Event loop.
Definition: Loop.h:37
Definition: StdDeque.h:50
Definition: ParallelTcpConnector.h:22
UV_EXTERN int uv_check_stop(uv_check_t *check)