From 227118866190a7fe17b42e8c589c475781c69f33 Mon Sep 17 00:00:00 2001 From: Yuqian Yang Date: Fri, 5 Sep 2025 23:52:33 +0800 Subject: Event loop poll. --- include/cru/base/platform/unix/EventLoop.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'include/cru/base/platform/unix/EventLoop.h') diff --git a/include/cru/base/platform/unix/EventLoop.h b/include/cru/base/platform/unix/EventLoop.h index b735ef26..784cb780 100644 --- a/include/cru/base/platform/unix/EventLoop.h +++ b/include/cru/base/platform/unix/EventLoop.h @@ -1,6 +1,5 @@ #pragma once -#include #if !defined(__unix) && !defined(__APPLE__) #error "This file can only be included on unix." #endif @@ -9,9 +8,12 @@ #include "../../Exception.h" #include "UnixFile.h" +#include #include #include +#include #include +#include namespace cru::platform::unix { class UnixTimerFile : public Object2 { @@ -84,13 +86,19 @@ class UnixEventLoop : public Object2 { action(std::move(action)) {} }; -private: + private: + bool CheckPoll(); + bool CheckTimer(); bool ReadTimerPipe(); -private: - + private: std::thread::id running_thread_; + std::vector polls_; + std::vector< + std::function().revents) revent)>> + poll_actions_; + std::atomic_int timer_tag_; std::vector timers_; -- cgit v1.2.3