|
1
|
|
|
2
|
- Contents
- Global Functions
- Member Functions
- Remember Functions
- Callable Interface
- Adaptors
- Currying
- Cloning
- Any Function
|
|
3
|
- A thread is the path traced by a function as it runs
- C++ supports several kinds of functions
- Global Function
- Direct Member Function
- Indirect Member Function
- How can we “thread” them?
|
|
4
|
- A global C function has no implicit object
- How can we “thread” a global C function?
|
|
5
|
- A global C++ function has no implicit object
- How can we “thread” a global C++ function?
|
|
6
|
- A member function has a this object
- How can we “thread” a member function?
|
|
7
|
- A member function can be called indirectly
- How can we “thread” a remember function?
|
|
8
|
- To make progress we need an interface
- All functions are callable
|
|
9
|
- An example of the Adapter pattern
|
|
10
|
- Example of adapting a global C function
|
|
11
|
- Arguments and return values can be curried
|
|
12
|
- Example of adapting a global C++ function
|
|
13
|
- Another example of the Adapter pattern
|
|
14
|
|
|
15
|
- A threaded function has lifetime constraints
- “function” must persist beyond scope of invoker
|
|
16
|
- Make the callable functions...
- Polymorphically copyable
- Polymorphically destructable
|
|
17
|
- This time with cloneability
|
|
18
|
- This time with cloneability
|
|
19
|
- Now we can create a function abstraction
- Easy to use, ready to be threaded
|
|
20
|
- Simplifies implementation...
|
|
21
|
|
|
22
|
- Clones the callable parameter
|
|
23
|
- Clones the function parameter
|
|
24
|
- Deletes the callable body
|
|
25
|
- Copy Before Release idiom
|
|
26
|
|