-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
43 lines (34 loc) · 817 Bytes
/
main.cpp
File metadata and controls
43 lines (34 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: main.cpp
* Author: hxw
*
* Created on September 18, 2017, 3:43 PM
*/
#include <cstdlib>
#include <unistd.h>
#include <iostream>
#include "../CThreadPool.h"
#include "Runable.h"
using namespace std;
#define TASK_SIZE 10
/*
*
*/
int main(int argc, char** argv) {
CThreadPool_t thread_pool;
thread_pool.start(3, 1000);
for (int i = 0; i < TASK_SIZE; ++i) {
Runable_t * r = new Runable_t();
r->set_task_id(i);
thread_pool.add(Runable_t::run,Runable_t::destroy, r);
}
std::cout << "add end" << std::endl;
sleep(2);
thread_pool.destroy();
return 0;
}