ObjFW  Check-in [a8113fd82c]

Overview
Comment:Pass the thread for thread exceptions.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: a8113fd82c55b5dad0e71d63e783f829abd3fa836364f89f4b6f28420f204fdd
User & Date: js on 2011-03-25 14:56:43
Other Links: manifest | tags
Context
2011-03-25
15:22
Pass the mutex for mutex exceptions. check-in: 343e80e785 user: js tags: trunk
14:56
Pass the thread for thread exceptions. check-in: a8113fd82c user: js tags: trunk
12:47
Add -[makeObjectsPerformSelector:] and friends to OFArray. check-in: 3a6d41c6a3 user: js tags: trunk
Changes

Modified src/OFThread.m from [88e3bb70b2] to [0dc35a7afe].

237
238
239
240
241
242
243
244

245
246
247
248
249
250

251
252
253
254
255
256
257
258
259

260
261
262
263
264
265
266
267
268
269

270
271
272
273
274
275
276
- (void)handleTermination
{
}

- (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;
}

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


	running = OF_THREAD_NOT_RUNNING;

	return retval;
}

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


	[object release];
	[retval release];

	[super dealloc];
}
@end







|
>





|
>








|
>









|
>







237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
- (void)handleTermination
{
}

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

	[self retain];

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

	running = OF_THREAD_RUNNING;
}

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

	running = OF_THREAD_NOT_RUNNING;

	return retval;
}

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

	[object release];
	[retval release];

	[super dealloc];
}
@end

Modified src/exceptions/OFHashAlreadyCalculatedException.h from [2e897eadfa] to [1d709ca1d5].

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
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, nonatomic) OFHash *hash;
#endif

/**

 * \param hash The hash which has already been calculated
 * \return A new hash already calculated exception
 */
+ newWithClass: (Class)class_
	  hash: (OFHash*)hash;

/**
 * Initializes an already allocated hash already calculated exception.
 *

 * \param hash The hash which has already been calculated
 * \return An initialized hash already calculated exception
 */
- initWithClass: (Class)class_
	   hash: (OFHash*)hash;

/**
 * \return The hash which has already been calculated
 */
- (OFHash*)hash;
@end







>









>











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
54
55
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, nonatomic) OFHash *hash;
#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param hash The hash which has already been calculated
 * \return A new hash already calculated exception
 */
+ newWithClass: (Class)class_
	  hash: (OFHash*)hash;

/**
 * Initializes an already allocated hash already calculated exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param hash The hash which has already been calculated
 * \return An initialized hash already calculated exception
 */
- initWithClass: (Class)class_
	   hash: (OFHash*)hash;

/**
 * \return The hash which has already been calculated
 */
- (OFHash*)hash;
@end

Modified src/exceptions/OFThreadJoinFailedException.h from [7463c74a82] to [01dedbef95].

12
13
14
15
16
17
18


19
20
21
22






























23
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFException.h"



/**
 * \brief An exception indicating that joining a thread failed.
 */
@interface OFThreadJoinFailedException: OFException






























@end







>
>




>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

12
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
53
54
55
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFException.h"

@class OFThread;

/**
 * \brief An exception indicating that joining a thread failed.
 */
@interface OFThreadJoinFailedException: OFException
{
	OFThread *thread;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, nonatomic) OFThread *thread;
#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param thread The thread which could not be joined
 * \return A new thread join failed exception
 */
+ newWithClass: (Class)class_
	thread: (OFThread*)thread;

/**
 * Initializes an already allocated thread join failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param thread The thread which could not be joined
 * \return An initialized thread join failed exception
 */
- initWithClass: (Class)class_
	 thread: (OFThread*)thread;

/**
 * \return The thread which could not be joined
 */
- (OFThread*)thread;
@end

Modified src/exceptions/OFThreadJoinFailedException.m from [c97467f279] to [31a64b538f].

14
15
16
17
18
19
20
21


22





































23
24
25
26
27
28
29
30
31
32
33





34
 * file.
 */

#include "config.h"

#import "OFThreadJoinFailedException.h"
#import "OFString.h"



@implementation OFThreadJoinFailedException





































- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"Joining a thread of class %@ failed! Most likely, another thread "
	    @"already waits for the thread to join.", inClass];

	return description;
}





@end








>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>











>
>
>
>
>

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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
 * file.
 */

#include "config.h"

#import "OFThreadJoinFailedException.h"
#import "OFString.h"

#import "OFNotImplementedException.h"

@implementation OFThreadJoinFailedException
+ newWithClass: (Class)class_
	thread: (OFThread*)thread
{
	return [[self alloc] initWithClass: class_
				    thread: thread];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
}

- initWithClass: (Class)class_
	 thread: (OFThread*)thread_
{
	self = [super initWithClass: class_];

	@try {
		thread = [thread_ retain];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[thread release];

	[super dealloc];
}

- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"Joining a thread of class %@ failed! Most likely, another thread "
	    @"already waits for the thread to join.", inClass];

	return description;
}

- (OFThread*)thread
{
	return thread;
}
@end

Modified src/exceptions/OFThreadStartFailedException.h from [003c0db024] to [e37cf48324].

12
13
14
15
16
17
18


19
20
21
22






























23
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFException.h"



/**
 * \brief An exception indicating that starting a thread failed.
 */
@interface OFThreadStartFailedException: OFException






























@end







>
>




>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

12
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
53
54
55
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFException.h"

@class OFThread;

/**
 * \brief An exception indicating that starting a thread failed.
 */
@interface OFThreadStartFailedException: OFException
{
	OFThread *thread;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, nonatomic) OFThread *thread;
#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param thread The thread which could not be started
 * \return An initialized thread start failed exception
 */
+ newWithClass: (Class)class_
	thread: (OFThread*)thread;

/**
 * Initializes an already allocated thread start failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param thread The thread which could not be started
 * \return An initialized thread start failed exception
 */
- initWithClass: (Class)class_
	 thread: (OFThread*)thread;

/**
 * \return The thread which could not be started
 */
- (OFThread*)thread;
@end

Modified src/exceptions/OFThreadStartFailedException.m from [d0e1d7f955] to [beb705e46b].

14
15
16
17
18
19
20
21


22





































23
24
25
26
27
28
29
30
31
32





33
 * file.
 */

#include "config.h"

#import "OFThreadStartFailedException.h"
#import "OFString.h"



@implementation OFThreadStartFailedException





































- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"Starting a thread of class %@ failed!", inClass];

	return description;
}





@end








>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>










>
>
>
>
>

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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
 * file.
 */

#include "config.h"

#import "OFThreadStartFailedException.h"
#import "OFString.h"

#import "OFNotImplementedException.h"

@implementation OFThreadStartFailedException
+ newWithClass: (Class)class_
	thread: (OFThread*)thread
{
	return [[self alloc] initWithClass: class_
				    thread: thread];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
}

- initWithClass: (Class)class_
	 thread: (OFThread*)thread_
{
	self = [super initWithClass: class_];

	@try {
		thread = [thread_ retain];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[thread release];

	[super dealloc];
}

- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"Starting a thread of class %@ failed!", inClass];

	return description;
}

- (OFThread*)thread
{
	return thread;
}
@end

Modified src/exceptions/OFThreadStillRunningException.h from [add1f91434] to [8e53069837].

12
13
14
15
16
17
18


19
20
21
22






























23
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFException.h"



/**
 * \brief An exception indicating that a thread is still running.
 */
@interface OFThreadStillRunningException: OFException






























@end







>
>




>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

12
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
53
54
55
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFException.h"

@class OFThread;

/**
 * \brief An exception indicating that a thread is still running.
 */
@interface OFThreadStillRunningException: OFException
{
	OFThread *thread;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, nonatomic) OFThread *thread;
#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param thread The thread which is still running
 * \return A new thread still running exception
 */
+ newWithClass: (Class)class_
	thread: (OFThread*)thread;

/**
 * Initializes an already allocated thread still running exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param thread The thread which is still running
 * \return An initialized thread still running exception
 */
- initWithClass: (Class)class_
	 thread: (OFThread*)thread;

/**
 * \return The thread which is still running
 */
- (OFThread*)thread;
@end

Modified src/exceptions/OFThreadStillRunningException.m from [ce8bbef205] to [e27ddf16cb].

14
15
16
17
18
19
20
21


22





































23
24
25
26
27
28
29
30
31
32
33





34
 * file.
 */

#include "config.h"

#import "OFThreadStillRunningException.h"
#import "OFString.h"



@implementation OFThreadStillRunningException





































- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"Deallocation of a thread of type %@ was tried, even though it "
	    @"was still running!", inClass];

	return description;
}





@end








>
>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>











>
>
>
>
>

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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
 * file.
 */

#include "config.h"

#import "OFThreadStillRunningException.h"
#import "OFString.h"

#import "OFNotImplementedException.h"

@implementation OFThreadStillRunningException
+ newWithClass: (Class)class_
	thread: (OFThread*)thread
{
	return [[self alloc] initWithClass: class_
				    thread: thread];
}

- initWithClass: (Class)class_
{
	Class c = isa;
	[self release];
	@throw [OFNotImplementedException newWithClass: c
					      selector: _cmd];
}

- initWithClass: (Class)class_
	 thread: (OFThread*)thread_
{
	self = [super initWithClass: class_];

	@try {
		thread = [thread_ retain];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[thread release];

	[super dealloc];
}

- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"Deallocation of a thread of type %@ was tried, even though it "
	    @"was still running!", inClass];

	return description;
}

- (OFThread*)thread
{
	return thread;
}
@end