0%

ThreadPool and WorkQueue

ThreadPool

  • 轮询处理
  • 定时触发

WorkQueue

  • FIFO机制
  • 提供process方法供TP调用

ThreadPool & WorkQueue

  • TP与WQ对应关系1:N
  • TP将便利WQs中的每个WQ的工作
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
   WorkQueue 1                       WorkQueue 2      ......          WorkQueue N

+---------+ +---------+ +---------+
| process | | process | | process |
+-----------+---------+ +--------------+---------+ +---------------+---------+
| | | | | |
| work 1 | --+ +------- | | | |
| | | | | | | |
+-----------+ | | +--------------+ +---------------+
| | | | | | | |
| work 2 | --+-+ | +--- | | ...... | |
| | | | | | | | | |
+-----------+ | | | | +--------------+ +---------------+
| | | | | | | | | |
| work 3 | --+-+-+ | | +- | | | |
| | | | | | | | | | | |
+-----------+ | | | | | | +--------------+ +---------------+
+-------------+ | | | | |
| +--------+ | | | +-----+
| | +----+ | | |
v v v v v v
+------+------+------+------+------+------+-----+-----+-----+----+-----+------+-----+----+-----+
| | | | | | | | | | | | |
| T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9 | T10| T11 | ...... | ThreadPool
| | | | | | | | | | | | |
+------+------+------+------+------+------+-----+-----+-----+----+-----+------+-----+----+-----+