-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunittest.cpp
More file actions
41 lines (36 loc) · 777 Bytes
/
unittest.cpp
File metadata and controls
41 lines (36 loc) · 777 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
#include <iostream>
#include <mutex>
#include <condition_variable>
#include <unistd.h>
#include <map>
#include <algorithm>
#include <utility>
#include <thread>
#include <typeindex>
#include <queue>
#include "threadpool.h"
void task()
{
usleep(1);
}
class Unittest {
public:
Unittest(int nboftask, int nbofworker) : max_task(nboftask), max_worker(nbofworker)
{
Threadpool fl(max_worker);
std::cout << "UnitTest; Nb of workers : " << max_worker << ", Nb of tasks : " << max_task << "\n";
for(int i=0; i<max_task; i++) {
fl.queue_task(1+std::rand()%99, task);
}
}
private:
int max_worker, max_task;
};
int main()
{
Unittest u1(100, 3);
Unittest u2(1000, 10);
Unittest u3(100000, 100);
Unittest u4(1, 10);
Unittest u5(0, 3);
}