ObjFW  Diff

Differences From Artifact [c73592c469]:

To Artifact [365e7ac8cd]:


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
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







+
+
















-
+





-
+







 */

#import "OFObject.h"
#import "OFList.h"

#import "threading.h"

@class OFDate;

/**
 * \brief A class for Thread Local Storage keys.
 */
@interface OFTLSKey: OFObject
{
@public
	of_tlskey_t key;
@protected
	void (*destructor)(id);
	of_list_object_t *listobj;
	BOOL initialized;
}

/**
 * \return A new autoreleased Thread Local Storage key
 */
+ tlsKey;
+ TLSKey;

/**
 * \param destructor A destructor that is called when the thread is terminated
 * \return A new autoreleased Thread Local Storage key
 */
+ tlsKeyWithDestructor: (void(*)(id))destructor;
+ TLSKeyWithDestructor: (void(*)(id))destructor;

+ (void)callAllDestructors;

/**
 * \return An initialized Thread Local Storage key
 */
- init;
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


98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115



116








117







118
119
120
121
122
123
124
74
75
76
77
78
79
80
81
82
83
84
85
86
87

88
89
90
91
92
93
94
95
96
97
98
99
100

101


102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120

121
122
123
124
125
126
127
128
129
130
131
132

133
134
135
136
137
138
139
140
141
142
143
144
145
146








+
+
+
+
+

-
+












-

-
-
+
+

















-
+
+
+

+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+







		OF_THREAD_NOT_RUNNING,
		OF_THREAD_RUNNING,
		OF_THREAD_WAITING_FOR_JOIN
	} running;
	id retval;
}

/**
 * \return A new, autoreleased thread
 */
+ thread;

/**
 * \param obj An object that is passed to the main method as a copy or nil
 * \return A new autoreleased thread
 * \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
 * \return The old object, autoreleased
 */
+ (id)setObject: (id)obj
      forTLSKey: (OFTLSKey*)key;
+ (void)setObject: (id)obj
	forTLSKey: (OFTLSKey*)key;

/**
 * Returns the object for the specified Thread Local Storage key.
 *
 * The returned object is <i>not</i> retained and autoreleased for performance
 * reasons!
 *
 * \param key The Thread Local Storage key
 */
+ (id)objectForTLSKey: (OFTLSKey*)key;

/**
 * \return The current thread or nil if we are in the main thread
 */
+ (OFThread*)currentThread;

/**
 * Suspends execution of the current thread for N milliseconds.
 * Suspends execution of the current thread for the specified time interval.
 *
 * \param sec The number of seconds to sleep
 */
+ (void)sleepForTimeInterval: (int64_t)sec;

/**
 * Suspends execution of the current thread for the specified time interval.
 *
 * \param sec The number of seconds to sleep
 * \param usec The number of microseconds to sleep
 */
+ (void)sleepForNMilliseconds: (unsigned int)msecs;
+ (void)sleepForTimeInterval: (int64_t)sec
		microseconds: (uint32_t)usec;

/**
 * Suspends execution of the current thread until the specified date.
 */
+ (void)sleepUntilDate: (OFDate*)date;

/**
 * Yields a processor voluntarily and moves the thread at the end of the queue
 * for its priority.
 */
+ (void)yield;