main.cpp

来自「模仿wiondws写的linux/freeBSD系统的IOCP」· C++ 代码 · 共 64 行

CPP
64
字号
#include "utility/thread.h"

#include "iocp/iocomplete.h"
#include "testthread.h"
#include "utility/fixobjpool.h"

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <iostream>
#include "cirbuf.h"
//fixObjPool_lockbase<userContext> context_pool;

int main(int argc, char **argv)
{

	listener      *lw = new listener(std::string("127.0.0.1"),atoi(argv[1]),5);

	Thread c(lw);

	IocpHandle iocp = CreateIocp(4096);
	lw->setTrig(iocp);
	c.start();

	completeWorker *workerA = new completeWorker(iocp);
	completeWorker *workerB = new completeWorker(iocp);
	completeWorker *workerC = new completeWorker(iocp);
	completeWorker *workerD = new completeWorker(iocp);
	
	Thread twa(workerA);
	Thread twb(workerB);
	Thread twc(workerC);
	Thread twd(workerD);
	twa.start();
	twb.start();
	twc.start();
	twd.start();


	getchar();
	CloseIocp(iocp);
	/*cirbuf<> cbuf;
	char buf[6];

	for(int i = 0; i < 1000; ++i)
	{
		if(6 != cbuf.put("hello",6))
		{
			printf("put error\n");
			return 0;
		}
		if(6 != cbuf.get(buf,6))
		{
			printf("get error\n");
			return 0;
		}
		printf("%s\n",buf);
		memset(buf,0,6);
	}*/

	return 0;
}

⌨️ 快捷键说明

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