Ai
1 Star 0 Fork 0

Shawy/2023Linux

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Task.hpp 613 Bytes
一键复制 编辑 原始数据 按行查看 历史
Shawy 提交于 2023-05-14 22:19 +08:00 . ThreadPool version TcpServer
#pragma once
#include "Log.hpp"
#include <string>
#include <functional>
// typedef std::function<void (int, const std::string &, uint16_t &, const std::string &)> func_t;
// 等价于
using func_t = std::function<void(int, const std::string &, uint16_t &, const std::string &)>;
class Task
{
public:
Task() {}
Task(int sockfd, const std::string ip, uint16_t port, func_t func)
: _sockfd(sockfd), _ip(ip), _port(port), _func(func)
{
}
~Task() {}
void operator()(const std::string &name)
{
_func(_sockfd, _ip, _port, name);
}
public:
int _sockfd;
std::string _ip;
uint16_t _port;
func_t _func;
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/shawyxy/2023-linux.git
git@gitee.com:shawyxy/2023-linux.git
shawyxy
2023-linux
2023Linux
main

搜索帮助