|
1
|
|
|
2
|
- Contents
- Threading API's
- Delegation Based Threads
- Inheritance Based Threads
- Thread Adaptor
- Needle and Thread
|
|
3
|
- A thread is the path traced by a function as it runs
- C++ supports several kinds of functions
- Global Function
- Member Function
- Remember Function
- How can we “thread” them?
|
|
4
|
|
|
5
|
|
|
6
|
|
|
7
|
- Lifetime of thread must be contained in lifetime of thread object
- Make thread object part of whole object
- Whole object becomes active
|
|
8
|
|
|
9
|
|
|
10
|
|
|
11
|
- Don't make threads auto-runnable
- Leads to non-deterministic bugs in many designs
- Initialisation and execution are separate concepts
- What if you want to delay execution?
|
|
12
|
|
|
13
|
|
|
14
|
- Can be refactored using Cheshire Cat idiom
|
|
15
|
|