thread_pool.h
来自「这是一个模拟电信计费的程序,非常详细,运用了线程池、消息队列和socket编程等」· C头文件 代码 · 共 57 行
H
57 行
#ifndef __THREAD_POOL_H__#define __THREAD_POOL_H__#include <pthread.h>#include <sys/types.h>#include <sys/ipc.h>#include <sys/msg.h>#include <unistd.h>#include <iostream>#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#include <sys/uio.h>#include <errno.h>#include <string.h>#include <sys/types.h>#include <sys/ipc.h>#include <sys/msg.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>using std::cout;using std::endl;#define LISTENQ 10#define Q_ID 0x500#define ERR_REPORT() { cout << strerror(errno) << endl; exit(-1); }#define __DEBUGclass thread_pool{protected: int total; int mqid;public: thread_pool(int _i = 1, int key = Q_ID); virtual ~thread_pool(); virtual void start(int port) = 0;public: struct info{ char user_name[50]; time_t start_time; time_t duration; char IP[16]; info() { strcpy(IP,"127.0.0.1"); } }; struct _mesg{ long mtype; char inf[sizeof(info)]; };};#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?