⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 listenthread.cpp

📁 LINUX 线程池源代码:Lock.cpp : 锁的操作 , 读锁可以并发 , 写锁独占. Queue.h : 队列的封装 , 队列的读和写都加了锁的保护. Socket.c
💻 CPP
字号:
#include "ListenThread.h"#include "Log.h"G_ListenThread::G_ListenThread(G_ThreadPool *pool) : g_threadPool(pool){	g_socket = new G_Socket();}G_ListenThread::~G_ListenThread(){	if(g_socket)	{		delete g_socket;		g_socket = NULL;	}}void G_ListenThread::Run(){	pause();	debug_output("Listen thread is starting ....\n");		int nSocket; 	while(1)	{		if(g_socket->Listen(nSocket))		{			debug_output("new client is connecting ....\n");			g_threadPool->pushSocket(nSocket);   ///填加到套接口队列			g_threadPool->continues();   ///通知线程池,运行起来,到套接口队列中取套接口		}	}}bool G_ListenThread::Bind(unsigned int nPort){	if(!g_socket->Bind(nPort))	{		debug_output("Bind port %d is faild\n" , nPort);		return false;	}	debug_output("Bind port %d is Successful\n" , nPort);	continues();	return true;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -