ObjFW  Diff

Differences From Artifact [06743d152c]:

To Artifact [e64db843c5]:


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
64
65
66
67
68
69
70


71
72
73
74
75
76
77
78
79



80
81
82
83
84
85
86
87







-
-
+
+







-
-
-
+







}

+ threadWithObject: (id)obj
{
	return [[[self alloc] initWithObject: obj] autorelease];
}

+ setObject: (OFObject*)obj
  forTLSKey: (OFTLSKey*)key
+ (id)setObject: (OFObject*)obj
      forTLSKey: (OFTLSKey*)key
{
	id old = of_tlskey_get(key->key);

	if (!of_tlskey_set(key->key, [obj retain]))
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];

	[old release];

	return self;
	return [old autorelease];
}

+ (id)objectForTLSKey: (OFTLSKey*)key
{
	return [[of_tlskey_get(key->key) retain] autorelease];
}

158
159
160
161
162
163
164
165

166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
156
157
158
159
160
161
162

163
164
165
166
167
168
169
170
171
172
173
174
175


176
177
178
179
180
181
182







-
+












-
-







	return nil;
}

- (void)handleTermination
{
}

- start
- (void)start
{
	if (running == OF_THREAD_RUNNING)
		@throw [OFThreadStillRunningException newWithClass: isa];

	[self retain];

	if (!of_thread_new(&thread, call_main, self)) {
		[self release];
		@throw [OFThreadStartFailedException newWithClass: isa];
	}

	running = OF_THREAD_RUNNING;

	return self;
}

- (id)join
{
	if (running == OF_THREAD_NOT_RUNNING || !of_thread_join(thread))
		@throw [OFThreadJoinFailedException newWithClass: isa];

299
300
301
302
303
304
305
306

307
308
309
310
311
312
313
314
315
316
317
318
319

320
321
322
323
324
325
326
327
328
329
330
331
332
333
295
296
297
298
299
300
301

302
303
304
305


306
307
308
309
310
311
312

313
314
315
316


317
318
319
320
321
322
323
324
325







-
+



-
-







-
+



-
-









		[self dealloc];
		@throw [OFInitializationFailedException newWithClass: c];
	}

	return self;
}

- lock
- (void)lock
{
	if (!of_mutex_lock(&mutex))
		@throw [OFMutexLockFailedException newWithClass: isa];

	return self;
}

- (BOOL)tryLock
{
	return of_mutex_trylock(&mutex);
}

- unlock
- (void)unlock
{
	if (!of_mutex_unlock(&mutex))
		@throw [OFMutexUnlockFailedException newWithClass: isa];

	return self;
}

- (void)dealloc
{
	of_mutex_free(&mutex);

	[super dealloc];
}
@end