WPILibC++ 2023.4.3-108-ge5452e3
Prepare.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_PREPARE_H_
6#define WPINET_UV_PREPARE_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 * Prepare handle.
22 * Prepare handles will generate a signal once per loop iteration, right
23 * before polling for I/O.
24 */
25class Prepare final : public HandleImpl<Prepare, uv_prepare_t> {
26 struct private_init {};
27
28 public:
29 explicit Prepare(const private_init&) {}
30 ~Prepare() noexcept override = default;
31
32 /**
33 * Create a prepare handle.
34 *
35 * @param loop Loop object where this handle runs.
36 */
37 static std::shared_ptr<Prepare> Create(Loop& loop);
38
39 /**
40 * Create a prepare handle.
41 *
42 * @param loop Loop object where this handle runs.
43 */
44 static std::shared_ptr<Prepare> 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 prior to polling for I/O.
60 */
62};
63
64} // namespace wpi::uv
65
66#endif // WPINET_UV_PREPARE_H_
SignalBase is an implementation of the observer pattern, through the use of an emitting object and sl...
Definition: Signal.h:495
bool Invoke(F &&f, Args &&... args) const
Definition: Handle.h:251
Handle.
Definition: Handle.h:273
uv_prepare_t * GetRaw() const noexcept
Get the underlying handle data structure.
Definition: Handle.h:288
Event loop.
Definition: Loop.h:37
Prepare handle.
Definition: Prepare.h:25
sig::Signal prepare
Signal generated once per loop iteration prior to polling for I/O.
Definition: Prepare.h:61
static std::shared_ptr< Prepare > Create(Loop &loop)
Create a prepare handle.
Prepare(const private_init &)
Definition: Prepare.h:29
void Start()
Start the handle.
~Prepare() noexcept override=default
void Stop()
Stop the handle.
Definition: Prepare.h:56
Definition: BFloat16.h:88
Definition: Buffer.h:18
UV_EXTERN int uv_prepare_stop(uv_prepare_t *prepare)