2
3
4
5
19
20
25
26
37
38
39
43
44
48
49
50
54
55
56
60
61
65
66
70
71
72
76
77
78
82
83
87
88
89
93
94
95
99
100
101
102
106
107
108
114
115
119
120
126
127
131
132
136
137
141
142
146
147
151
152
156
157
161
162
166
167
171
172
177
178
184
185
189
190
194
195
196
202
203
#define SPICES_PROFILE_ZONE
Wrapper of readwrite buffer.
Wrapper of SOCKET'S Event.
ThreadPool of Multiple threading EventLoop.
EventLoopThreadWrapper()
Constructor Function.
virtual ~EventLoopThreadWrapper()
Destructor Function.
static EventLoop *& GetInst(InetAddress *address=nullptr)
Get EventLoop Instance. @reutrn Returns EventLoop Instance.
EventLoop * instance
This thread EventLoop instance.
Wrapper of Instance/Delete ThreadCache in thread.
EventLoop & operator=(const EventLoop &)=delete
Copy Assignment Operation.
void HandleWakeUp()
Handle WakeUp notify by read one byte data.
std::vector< Functor > m_PendingFunctors
Delay functors.
void DoPendingFunctors()
Execute all pending functors.
std::shared_ptr< Poller > m_Poller
Poller instance.
std::atomic_bool m_IsCallingPendingFunctors
True if is execute pending functors.
std::atomic_bool m_IsLooping
True if is in Looping.
bool HasChannel(Channel *channel) const
Determine if channel is inside poller.
std::mutex m_Mutex
Mutex for PendingFunctors.
EventLoop(const EventLoop &)=delete
Copy Constructor Function.
std::atomic_bool m_IsQuit
True if is quit from Looping.
EventLoop(InetAddress *address=nullptr)
Constructor Function.
void WakeUp()
WakeUp a thread, which wait on recv, by sending one byte data.
std::unique_ptr< Channel > m_WeakupChannel
Wakeup Channel.
void Loop()
Start Event Loop.
bool IsInLoopThread() const
Determine if current thread is in eventloop thread.
void RunInLoop(Functor cb)
Push functor to pending functors.
~EventLoop()
Destructor Function.
Socket m_WakeupFd
Wakeup Socket.
DWORD m_ThreadId
Thread's identify, which is running this EventLoop.
void QueueInLoop(Functor cb)
Execute functor in EventLoop thread.
void UpdateChannel(Channel *channel) const
Update channel state with poller.
void Quit()
Quit from Event Loop.
ChannelList m_ActiveChannels
Channels with events.
void RemoveChannel(Channel *channel) const
Remove channel from poller.
Wrapper of Poller and wakeup socket to acceptor(SubLoop).
const Version GetVersion() const
Get Http Version.
std::string GetHeader(const std::string &name) const
Get a Header from this HttpRequest.
HttpResponse(bool close)
Constructor Function.
void AppendToBuffer(Buffer *output)
Append this response to Buffer.
bool CloseConnection() const
Get CloseConnection.
HttpServer & operator=(const HttpServer &)=delete
Copy Assignment Operation.
HttpServer(const HttpServer &)=delete
Copy Constructor Function.
void OnRequest(const TcpConnectionPtr &connection, const HttpRequest &request)
HttpCallback m_HttpCallback
virtual ~HttpServer()=default
Destructor Function.
void OnConnection(const TcpConnectionPtr &connection)
HttpServer(const InetAddress &listenAddress, int idleSeconds, TcpServer::Option option=TcpServer::Option::NoReusePort)
Constructor Function.
void Start(int threadSize) const
Start ThreadPool and call listen on acceptor.
WeakConnectionList m_ConnectionList
void OnMessage(const TcpConnectionPtr &connection, Buffer *buf)
This class is Wrapper of current socket address.
Inherit from this and Implement Specific Poller.
This class is Wrapper of socket.
Combine of Socket Connection data.
void SetThreadInitCallback(const ThreadInitCallback &cb)
Set Thread initialize Call back.
void AddMessageCallback(const DelegateMessageCallback::Agent &cb)
Add Message Call back.
void Start(int threadSize) const
Start ThreadPool and call listen on acceptor.
std::shared_ptr< EventLoopThreadPool > m_ThreadPool
ThreadPool.
void NewConnection(SOCKET socketFd, const InetAddress &peerAddress)
Handle New Connection to Acceptor.
void RemoveConnectionInLoop(const TcpConnectionPtr &connection)
Remove a TcpConnection InLoop.
TcpServer(const TcpServer &)=delete
Copy Constructor Function.
ConnectionMap m_Connections
All TcpConnections.
DelegateWriteCompleteCallback m_WriteCompleteCallback
WriteCompleteCallback.
void RemoveConnection(const TcpConnectionPtr &connection)
Remove a TcpConnection.
TcpServer(const InetAddress &listenAddress, Option option=Option::NoReusePort)
Constructor Function.
TcpServer & operator=(const TcpServer &)=delete
Copy Assignment Operation.
ThreadInitCallback m_ThreadInitCallback
ThreadInitCallback.
std::unique_ptr< Acceptor > m_Acceptor
Acceptor.
std::string m_IpPort
TcpServer Ip and Port.
void AddConnectionCallback(const DelegateConnectionCallback::Agent &cb)
Add Connection Call back.
virtual ~TcpServer()
Destructor Function.
DelegateConnectionCallback m_ConnectionCallback
ConnectionCallback.
int m_NextConnectedId
Next Connection id.
DelegateMessageCallback m_MessageCallback
MessageCallback.
void AddWriteCompleteCallback(const DelegateWriteCompleteCallback::Agent &cb)
Add WriteComplete Call back.