forked from foshougua/network-dash
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIdleThreadContainer.cpp
More file actions
68 lines (52 loc) · 1.3 KB
/
IdleThreadContainer.cpp
File metadata and controls
68 lines (52 loc) · 1.3 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*************************************************************************
> File Name: IdleThreadContainer.cpp
> Author:
> Mail:
> Created Time: 2017年05月09日 星期二 09时35分01秒
************************************************************************/
#include "IdleThreadContainer.h"
#include "MyThread.h"
#include <iostream>
#include<algorithm>
using std::cout;
using std::endl;
IdleThreadContainer::IdleThreadContainer()
{
}
IdleThreadContainer::~IdleThreadContainer()
{
int i = 0;
for (Iterator it = idle_thread_container_.begin(); it != idle_thread_container_.end(); it++)
{
cout << i++ << endl;
delete *it;
}
}
std::vector<MyThread*>::size_type IdleThreadContainer::size()
{
return idle_thread_container_.size();
}
void IdleThreadContainer::push(MyThread *m)
{
idle_thread_container_.push_back(m);
}
void IdleThreadContainer::pop()
{
idle_thread_container_.pop_back();
}
void IdleThreadContainer::erase(MyThread *m)
{
idle_thread_container_.erase(find(idle_thread_container_.begin(), idle_thread_container_.end(), m));
}
void IdleThreadContainer::assign(int number, MyThreadPool *m)
{
for (int i = 0; i < number; i++)
{
MyThread *p = new MyThread(m);
idle_thread_container_.push_back(p);
}
}
MyThread* IdleThreadContainer::top()
{
return idle_thread_container_.back();
}