ObjFW  Check-in [19a1167518]

Overview
Comment:Only cancel a thread on -[dealloc] if it's still running.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 19a11675186903648327b7d77c2a9001c3b2299f641583aa4711ffc94d3c4ba0
User & Date: js on 2009-10-18 19:32:54
Other Links: manifest | tags
Context
2009-10-19
08:29
Fix a bug in -[freeMemory:]. check-in: 6e357d636d user: js tags: trunk
2009-10-18
19:32
Only cancel a thread on -[dealloc] if it's still running. check-in: 19a1167518 user: js tags: trunk
19:25
Fix missing retains in OFList. check-in: 5c006e80bb user: js tags: trunk
Changes

Modified src/OFThread.h from [cae32ff3af] to [a3c7f4a17c].

51
52
53
54
55
56
57

58
59
60
61
62
63
64
 * To use it, you should create a new class derived from it and reimplement
 * main.
 */
@interface OFThread: OFObject
{
	id object;
	of_thread_t thread;


@public
	id retval;
}

/**
 * \param obj An object that is passed to the main method as a copy or nil







>







51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
 * To use it, you should create a new class derived from it and reimplement
 * main.
 */
@interface OFThread: OFObject
{
	id object;
	of_thread_t thread;
	BOOL running;

@public
	id retval;
}

/**
 * \param obj An object that is passed to the main method as a copy or nil

Modified src/OFThread.m from [3dbf79b6f7] to [6b5ac95014].

63
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
98
99
100
101
102
103
- initWithObject: (id)obj
{
	self = [super init];
	object = [obj copy];

	if (!of_thread_new(&thread, call_main, self)) {
		Class c = isa;

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



	return self;
}

- main
{
	return nil;
}

- join
{
	of_thread_join(thread);


	return retval;
}

- (void)dealloc
{
	/*
	 * No need to handle errors - if canceling the thread fails, we can't
	 * do anything anyway. Most likely, it finished already or was already
	 * canceled.
	 */

	of_thread_cancel(thread);

	[object release];
	[super dealloc];
}
@end

@implementation OFTLSKey







>



>
>












>











>
|







63
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
98
99
100
101
102
103
104
105
106
107
108
- initWithObject: (id)obj
{
	self = [super init];
	object = [obj copy];

	if (!of_thread_new(&thread, call_main, self)) {
		Class c = isa;
		[object release];
		[super dealloc];
		@throw [OFInitializationFailedException newWithClass: c];
	}

	running = YES;

	return self;
}

- main
{
	return nil;
}

- join
{
	of_thread_join(thread);
	running = NO;

	return retval;
}

- (void)dealloc
{
	/*
	 * No need to handle errors - if canceling the thread fails, we can't
	 * do anything anyway. Most likely, it finished already or was already
	 * canceled.
	 */
	if (running)
		of_thread_cancel(thread);

	[object release];
	[super dealloc];
}
@end

@implementation OFTLSKey