![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
多线程
文章平均质量分 87
huangtianyi1994
奋斗吧 少年!!
展开
-
仿照nginx手写线程池采用c++11实现支持跨平台
1、为了方便线程和任务的管理,我们分别将任务和线程用双向链表串起来。 下面介绍关于线程节点及任务节点的数据结构 线程节点 typedef struct NWORKER { thread threadid; int terminate; //控制退出 struct NWORKER* next;//把线程串起来方便管理退出 struct NWORKER* prev; struct NMANAGER* poo...原创 2021-10-12 14:56:54 · 178 阅读 · 0 评论 -
Windows Linux 跨平台简单tcp实现 基于设置socket非阻塞,select连接超时控制。
#ifdef WIN32 #pragma once #ifdef XSOCKET_EXPORTS #define XSOCKET_API __declspec(dllexport) #else #define XSOCKET_API __declspec(dllimport) #endif #else #define XSOCKET_API #endif // WIN32 //tcp封装 在windows下封装成dll 在linux下封装成.so #include<string> ...原创 2020-07-20 13:49:04 · 329 阅读 · 0 评论 -
C++11 future async异步调用函数 基础用法了解
/*解决主线程和子线程后期同步的问题 类似于windows中的事件*/ #include "iostream" #include "future" #include "thread" using namespace std; int main(void) { promise<int>proms;//构建一个承若 auto& fut = proms.get_...原创 2020-04-22 17:31:05 · 438 阅读 · 0 评论