main.c

来自「通用 linux 线程池, 使用 C++ 编写, 具有良好的扩展性.」· C语言 代码 · 共 46 行

C
46
字号
#include "shared_ptr.h"#include "lock.h"#include <iostream>#include <pthread.h>#include <string>#include <unistd.h>#include "thread.h"#include "threadpool.h"#include "myjob.h"using namespace std;using namespace util;#include "mythread.h"#include "myjob.h"int main(){	shared_ptr<ThreadPool> mPool = shared_ptr<ThreadPool>(new ThreadPool(5));	shared_ptr<BaseJob> mJob = shared_ptr<BaseJob>(new MyJob);		string str;	while(1)	{		cout<<"please input add ? \n";		cin>>str;		if(str == "exit")			break;		else if(str == "stop")		{			mPool->stop();						cout<<"the pool is destroying.....\n";		}		else if(str == "add")		{			for(int i = 0; i< 30; i++)				mPool->addJob(mJob);		}		else			cout<<"bad command .. \n";	}	return 0;}

⌨️ 快捷键说明

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