ObjFW  Check-in [70b77b9b3a]

Overview
Comment:Detach threads when we never joined them.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 70b77b9b3a85d0fe2a88362576d3fe90a5de32bde9323ccb943962d73f539986
User & Date: js on 2011-04-12 12:43:47
Other Links: manifest | tags
Context
2011-04-12
13:06
Detach the thread if it was not joined but we want to re-run it. check-in: 9825bfe451 user: js tags: trunk
12:43
Detach threads when we never joined them. check-in: 70b77b9b3a user: js tags: trunk
2011-04-11
12:29
Improve order of includes. check-in: 8090e85bbd user: js tags: trunk
Changes

Modified src/OFThread.m from [fd76b79d25] to [ec95778541].

268
269
270
271
272
273
274







275
276
277
278
279
280
281

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








	[object release];
	[retval release];

	[super dealloc];
}
@end








>
>
>
>
>
>
>







268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288

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

	/*
	 * We should not be running anymore, but call detach in order to free
	 * the resources.
	 */
	if (running == OF_THREAD_WAITING_FOR_JOIN)
		of_thread_detach(thread);

	[object release];
	[retval release];

	[super dealloc];
}
@end

Modified src/threading.h from [b5ecf36784] to [d7813d4c61].

86
87
88
89
90
91
92











93
94
95
96
97
98
99
		return NO;

	CloseHandle(thread);

	return YES;
#endif
}












static OF_INLINE void
of_thread_exit()
{
#if defined(OF_HAVE_PTHREADS)
	pthread_exit(NULL);
#elif defined(_WIN32)







>
>
>
>
>
>
>
>
>
>
>







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
		return NO;

	CloseHandle(thread);

	return YES;
#endif
}

static OF_INLINE BOOL
of_thread_detach(of_thread_t thread)
{
#if defined(OF_HAVE_PTHREADS)
	return !pthread_detach(thread);
#elif defined(_WIN32)
	/* FIXME */
	return YES;
#endif
}

static OF_INLINE void
of_thread_exit()
{
#if defined(OF_HAVE_PTHREADS)
	pthread_exit(NULL);
#elif defined(_WIN32)