Giter Site home page Giter Site logo

learn_epollserver's Introduction

Learn_EpollServer

个人学习项目 以epoll去触发事件流向, 读【采用了两阶段{包头+包体}】,然后通过触发线程处理我们的业务逻辑 发【单独的线程去处理我们要发送的数据】 我们采用先write,如果没有发完,再加到我们的epoll事件


ngx_read_request_handler													//读操作
	void ngx_wait_request_handler_proc_p1(lpngx_connection_t pConn,bool &isflood); 		//包头收完整后的处理,我们称为包处理阶段1:写成函数,方便复用
	void ngx_wait_request_handler_proc_plast(lpngx_connection_t pConn,bool &isflood);      //收到一个完整包后的处理,放到一个函数中,方便调用	
		 g_threadpool.inMsgRecvQueueAndSignal(pConn->precvMemPointer); 				//入消息队列并触发线程处理消息
		 	Call();                    										//可以激发一个线程来干活了,刺激ThreadFunc线程函数
				g_socket.threadRecvProcFunc(jobbuf);    						//处理消息队列中来的消息
    					(this->*statusHandler[imsgCode])(p_Conn,pMsgHeader,(char *)pPkgBody,pkglen-m	_iLenPkgHeader); 	//(4)调用消息码对应的成员函数来处理
					// 收包, 检测crc, 填充包
					msgSend(p_sendbuf);  
						m_MsgSendQueue.push_back(psendbuf);     // void* CSocekt::ServerSendQueueThread(void* threadData)  //专门用来发送数据的线程, 交给发送线程处理
						sem_post(&m_semEventSendQueue)



ngx_write_request_handler													//写操作
	sendproc(pConn,pConn->psendbuf,pConn->isendlen);
	sem_post(&m_semEventSendQueue);											//触发线程处理  
		void* CSocekt::ServerSendQueueThread(void* threadData)						//专门用来发送数据的线程
		sem_wait(&pSocketObj->m_semEventSendQueue)								//等待触发
          	sendsize = pSocketObj->sendproc(p_Conn,p_Conn->psendbuf,p_Conn->isendlen); //注意参数

learn_epollserver's People

Contributors

adonggu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.