13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#include <pthread.h>
#else
#include <windows.h>
#endif
#import "OFObject.h"
/**
* The OFThread class provides portable threads.
*
* To use it, you should create a new class derived from it and reimplement
* main.
*/
@interface OFThread: OFObject
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
|
#include <pthread.h>
#else
#include <windows.h>
#endif
#import "OFObject.h"
/**
* A Thread Local Storage key.
*/
@interface OFTLSKey: OFObject
{
@public
#ifndef _WIN32
pthread_key_t key;
#else
DWORD key;
#endif
}
/**
* \param destructor A destructor that is called when the thread is terminated
* \return A new autoreleased Thread Local Storage key
*/
+ tlsKeyWithDestructor: (void(*)(void*))destructor;
/**
* \param destructor A destructor that is called when the thread is terminated
* \return An initialized Thread Local Storage key
*/
- initWithDestructor: (void(*)(void*))destructor;
@end
/**
* The OFThread class provides portable threads.
*
* To use it, you should create a new class derived from it and reimplement
* main.
*/
@interface OFThread: OFObject
|
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
/**
* \param obj An object that is passed to the main method
* \return A new, autoreleased thread
*/
+ threadWithObject: (id)obj;
/**
* \param obj An object that is passed to the main method
* \return An initialized OFThread.
*/
- initWithObject: (id)obj;
/**
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
/**
* \param obj An object that is passed to the main method
* \return A new, autoreleased thread
*/
+ threadWithObject: (id)obj;
/**
* Sets the Thread Local Storage for the specified key.
*
* The specified object is first retained and then the object stored before is
* released. You can specify nil as object if you want the old object to be
* released and don't want any new object for the TLS key.
*
* \param key The Thread Local Storage key
* \param obj The object the Thread Local Storage key will be set to
*/
+ setObject: (id)obj
forTLSKey: (OFTLSKey*)key;
/**
* Returns the object for the specified Thread Local Storage key.
*
* \param key The Thread Local Storage key
*/
+ (id)objectForTLSKey: (OFTLSKey*)key;
/**
* \param obj An object that is passed to the main method
* \return An initialized OFThread.
*/
- initWithObject: (id)obj;
/**
|