SpiecsEngine
 
Loading...
Searching...
No Matches

◆ EventLoop() [1/2]

Spices::Net::EventLoop::EventLoop ( InetAddress * address = nullptr)

Constructor Function.

Parameters
[in]addressListenAddress.

Definition at line 22 of file EventLoop.cpp.

23 : m_IsLooping(false)
24 , m_IsQuit(false)
26 {
28
29 m_ThreadId = GetCurrentThreadId();
32 if (address)
33 {
34 m_WakeupFd.Connect(address);
35 }
36 m_WeakupChannel = std::make_unique<Channel>(m_WakeupFd.Fd(), this);
37
38 m_WeakupChannel->SetReadCallback([=]() { HandleWakeUp(); });
39 m_WeakupChannel->EnableReading();
40 }
#define SPICES_PROFILE_ZONE
void HandleWakeUp()
Handle WakeUp notify by read one byte data.
std::shared_ptr< Poller > m_Poller
Poller instance.
Definition EventLoop.h:148
std::atomic_bool m_IsCallingPendingFunctors
True if is execute pending functors.
Definition EventLoop.h:138
std::atomic_bool m_IsLooping
True if is in Looping.
Definition EventLoop.h:128
std::atomic_bool m_IsQuit
True if is quit from Looping.
Definition EventLoop.h:133
std::unique_ptr< Channel > m_WeakupChannel
Wakeup Channel.
Definition EventLoop.h:158
Socket m_WakeupFd
Wakeup Socket.
Definition EventLoop.h:153
DWORD m_ThreadId
Thread's identify, which is running this EventLoop.
Definition EventLoop.h:143
static std::shared_ptr< Poller > DefaultPoller(EventLoop *loop)
Create Default Poller.
Definition Poller.cpp:25
void Connect(InetAddress *connectAddress) const
Connect to socket.
Definition Socket.cpp:62
void Create()
Create Non Blocking Socket.
Definition Socket.cpp:27
const SOCKET Fd() const
Get this socket fd.
Definition Socket.h:60

References EventLoop().

Referenced by EventLoop(), and Spices::Net::EventLoopThreadWrapper::GetInst().