SpiecsEngine
 
Loading...
Searching...
No Matches
Spices::Net::EventLoop Class Reference

Wrapper of Poller and wakeup socket to acceptor(SubLoop). More...

#include <EventLoop.h>

Public Types

using Functor = std::function<void()>
 
using ChannelList = std::vector<Channel*>
 

Public Member Functions

 EventLoop (InetAddress *address=nullptr)
 Constructor Function.
 
 ~EventLoop ()
 Destructor Function.
 
 EventLoop (const EventLoop &)=delete
 Copy Constructor Function.
 
EventLoopoperator= (const EventLoop &)=delete
 Copy Assignment Operation.
 
void Loop ()
 Start Event Loop.
 
void Quit ()
 Quit from Event Loop.
 
void RunInLoop (Functor cb)
 Push functor to pending functors.
 
void QueueInLoop (Functor cb)
 Execute functor in EventLoop thread.
 
void WakeUp ()
 WakeUp a thread, which wait on recv, by sending one byte data.
 
void UpdateChannel (Channel *channel) const
 Update channel state with poller.
 
void RemoveChannel (Channel *channel) const
 Remove channel from poller.
 
bool HasChannel (Channel *channel) const
 Determine if channel is inside poller.
 
bool IsInLoopThread () const
 Determine if current thread is in eventloop thread.
 

Private Member Functions

void HandleWakeUp ()
 Handle WakeUp notify by read one byte data.
 
void DoPendingFunctors ()
 Execute all pending functors.
 

Private Attributes

std::atomic_bool m_IsLooping
 True if is in Looping.
 
std::atomic_bool m_IsQuit
 True if is quit from Looping.
 
std::atomic_bool m_IsCallingPendingFunctors
 True if is execute pending functors.
 
DWORD m_ThreadId
 Thread's identify, which is running this EventLoop.
 
std::shared_ptr< Pollerm_Poller
 Poller instance.
 
Socket m_WakeupFd
 Wakeup Socket.
 
std::unique_ptr< Channelm_WeakupChannel
 Wakeup Channel.
 
ChannelList m_ActiveChannels
 Channels with events.
 
std::vector< Functorm_PendingFunctors
 Delay functors.
 
std::mutex m_Mutex
 Mutex for PendingFunctors.
 

Detailed Description

Wrapper of Poller and wakeup socket to acceptor(SubLoop).

Definition at line 27 of file EventLoop.h.


The documentation for this class was generated from the following files: