35class Loop final :
public std::enable_shared_from_this<Loop> {
36 struct private_init {};
39 using Time = std::chrono::duration<uint64_t, std::milli>;
47 explicit Loop(
const private_init&)
noexcept;
110 m_tid = std::this_thread::get_id();
112 m_tid = std::thread::id{};
153 return std::pair{to == -1,
Time{to}};
229 template <
typename T =
void>
231 return std::static_pointer_cast<T>(m_data);
238 void SetData(std::shared_ptr<void> data) { m_data = std::move(data); }
258 std::shared_ptr<void> m_data;
261 std::atomic<std::thread::id> m_tid;
262 bool m_closing =
false;
Handle.
Definition Handle.hpp:32
std::thread::id GetThreadId() const
Get the thread id of the loop thread.
Definition Loop.hpp:244
bool IsClosing() const
Return the loop closed flag.
Definition Loop.hpp:83
void UpdateTime() noexcept
Update the event loop’s concept of now.
Definition Loop.hpp:179
bool IsAlive() const noexcept
Check if there are active resources.
Definition Loop.hpp:121
void SetClosing()
Set the loop closing flag.
Definition Loop.hpp:76
Loop(const private_init &) noexcept
void Close()
Release all internal loop resources.
void SetData(std::shared_ptr< void > data)
Sets user-defined data.
Definition Loop.hpp:238
Time Now() const noexcept
Return the current timestamp in milliseconds.
Definition Loop.hpp:168
static std::shared_ptr< Loop > GetDefault()
Create the default event loop.
void Walk(wpi::util::function_ref< void(Handle &)> callback)
Walk the list of handles.
static std::shared_ptr< Loop > Create()
Create a new event loop.
Loop & operator=(Loop &&oth)=delete
void Fork()
Reinitialize any kernel state necessary in the child process after a fork(2) system call.
Loop & operator=(const Loop &)=delete
int GetDescriptor() const noexcept
Get backend file descriptor.
Definition Loop.hpp:142
wpi::util::sig::Signal< Error > error
Error signal.
Definition Loop.hpp:249
bool Run(Mode mode=kDefault)
Run the event loop.
Definition Loop.hpp:109
void Stop() noexcept
Stop the event loop.
Definition Loop.hpp:131
std::shared_ptr< T > GetData() const
Gets user-defined data.
Definition Loop.hpp:230
std::chrono::duration< uint64_t, std::milli > Time
Definition Loop.hpp:39
void ReportError(int err)
Reports error.
Definition Loop.hpp:255
Loop(const Loop &)=delete
uv_loop_t * GetRaw() const noexcept
Get the underlying event loop data structure.
Definition Loop.hpp:223
std::pair< bool, Time > GetTimeout() const noexcept
Get the poll timeout.
Definition Loop.hpp:151
Mode
Definition Loop.hpp:41
@ kNoWait
Definition Loop.hpp:44
@ kOnce
Definition Loop.hpp:43
@ kDefault
Definition Loop.hpp:42
An efficient, type-erasing, non-owning reference to a callable.
Definition function_ref.hpp:31
Error
Definition def.inc:106
Definition StringMap.hpp:773
Definition Errors.hpp:112
Definition Prepare.hpp:14
SignalBase< detail::NullMutex, T... > Signal
Specialization of SignalBase to be used in single threaded contexts.
Definition Signal.h:809
UV_EXTERN void uv_stop(uv_loop_t *)
uv_run_mode
Definition uv.h:265
@ UV_RUN_NOWAIT
Definition uv.h:268
@ UV_RUN_ONCE
Definition uv.h:267
@ UV_RUN_DEFAULT
Definition uv.h:266
UV_EXTERN int uv_backend_timeout(const uv_loop_t *)
UV_EXTERN int uv_backend_fd(const uv_loop_t *)
UV_EXTERN int uv_run(uv_loop_t *, uv_run_mode mode)
UV_EXTERN uint64_t uv_now(const uv_loop_t *)
UV_EXTERN int uv_loop_alive(const uv_loop_t *loop)
UV_EXTERN void uv_update_time(uv_loop_t *)
struct uv_loop_s uv_loop_t
Definition uv.h:215