1 Star 0 Fork 0

邢成功/mymuduo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
acceptor.h 823 Bytes
一键复制 编辑 原始数据 按行查看 历史
邢成功 提交于 2022-06-02 21:33 . complete the acceptor class code
#pragma once
#include"noncopyable.h"
#include"socket.h"
#include"channel.h"
#include<functional>
class EventLoop;
class InetAddress;
class Acceptor : noncopyable
{
public:
using NewConnectionCallback = std::function<void(int fd, const InetAddress&)>;
/* 此构造的三个参数本身也是TcpServer的三个参数 */
Acceptor(EventLoop * loop, const InetAddress & listenAddr, bool reusePort);
~Acceptor();
public:
void listen();
public:
void setNewConnectionCallback(const NewConnectionCallback &cb)
{
m_newConnectionCallback = cb;
}
bool listenning() const {return m_listenning;}
private:
void handleRead();
private:
EventLoop * m_loop;
Socket m_acceptSocket;
Channel m_acceptChannel;
NewConnectionCallback m_newConnectionCallback;
bool m_listenning;
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/mrcan/mymuduo.git
git@gitee.com:mrcan/mymuduo.git
mrcan
mymuduo
mymuduo
master

搜索帮助