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

Wrapper of SOCKET'S Event. More...

#include <Channel.h>

Public Types

enum  EventBits { None = 0 , Read = EPOLLIN | EPOLLPRI , Write = EPOLLOUT }
 
enum class  PollState { New = 0 , Added = 1 , Deleted = 2 }
 
using EventCallback = std::function<void()>
 
using EventFlags = uint32_t
 

Public Member Functions

 Channel (SOCKET fd, EventLoop *loop)
 Constructor Function.
 
 ~Channel ()=default
 Destructor Function.
 
 Channel (const Channel &)=delete
 Copy Constructor Function.
 
Channeloperator= (const Channel &)=delete
 Copy Assignment Operation.
 
void HandleEvent () const
 Handle happened events on fd.
 
void SetReadCallback (EventCallback cb)
 Set Read Event Callback.
 
void SetWriteCallback (EventCallback cb)
 Set Write Event Callback.
 
void SetCloseCallback (EventCallback cb)
 Set Close Event Callback.
 
void SetErrorCallback (EventCallback cb)
 Set Error Event Callback.
 
void Tie (const std::shared_ptr< void > &obj)
 
SOCKET Fd () const
 Get this SOCKET.
 
int Events () const
 Get this Events type.
 
void SetRevents (int revt)
 Set this REvents type.
 
void EnableReading ()
 Enable Read event.
 
void DisableReading ()
 Disable Read event.
 
void EnableWriting ()
 Enable Write event.
 
void DisableWriting ()
 Disable Write event.
 
void DisableAll ()
 Disable All event.
 
bool IsNoneEvent () const
 Determine whether the event is a None Event.
 
bool IsWriting () const
 Determine whether the event is a Write Event.
 
bool IsReading () const
 Determine whether the event is a Read Event.
 
PollState GetPollState () const
 Get Poll State.
 
void SetPollState (PollState state)
 Set Poll State.
 
void Remove ()
 Remove this Channel state from Poller.
 

Private Member Functions

void Update ()
 Update this Channel state to Poller.
 
void HandleEventsWithGuard () const
 Internal handle happened events on fd.
 

Private Attributes

SOCKET m_Fd
 This channel interested SOCKET.
 
EventLoopm_Loop
 This channel interested EventLoop.
 
EventFlags m_Events
 This SOCKET interested Events type.
 
int m_Revents
 Current happened event type.
 
PollState m_PollState
 This channel PollState.
 
std::optional< std::weak_ptr< void > > m_Tie
 
EventCallback m_ReadCallback
 Read Event Callback.
 
EventCallback m_WriteCallback
 Write Event Callback.
 
EventCallback m_CloseCallback
 Close Event Callback.
 
EventCallback m_ErrorCallback
 Error Event Callback.
 

Detailed Description

Wrapper of SOCKET'S Event.

Definition at line 26 of file Channel.h.


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