ObjFW  Check-in [cc17787021]

Overview
Comment:Minor fix for -[join] in OFThread.

We also want to be able to join a thread that is still running, this
change allows that.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: cc17787021a348db0010fbc178ce30703b5a5581aafe6dad0785deaa47dc78fa
User & Date: js on 2010-04-10 21:43:47
Other Links: manifest | tags
Context
2010-04-10
21:49
Retain the thread in -[start] first to prevent a race condition. check-in: 82fe4443e2 user: js tags: trunk
21:43
Minor fix for -[join] in OFThread. check-in: cc17787021 user: js tags: trunk
21:37
Don't set errno in sockets on Win32. check-in: 1e35805366 user: js tags: trunk
Changes

Modified src/OFThread.m from [4081c149ee] to [12d687f3c9].

146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
	[self retain];

	return self;
}

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

	running = OF_THREAD_NOT_RUNNING;

	return retval;
}








|







146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
	[self retain];

	return self;
}

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

	running = OF_THREAD_NOT_RUNNING;

	return retval;
}

Modified tests/OFThreadTests.m from [0e44f6026c] to [1c2bd09aff].

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	TestThread *t;
	OFTLSKey *key;

	TEST(@"+[threadWithObject:]",
	    (t = [TestThread threadWithObject: @"foo"]))

	TEST(@"-[run]", [t start])

	TEST(@"-[join]", [[t join] isEqual: @"success"])

	TEST(@"OFTLSKey's +[tlsKey]", (key = [OFTLSKey tlsKey]))

	TEST(@"+[setObject:forTLSKey:]", [OFThread setObject: @"foo"
						   forTLSKey: key])







|







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	TestThread *t;
	OFTLSKey *key;

	TEST(@"+[threadWithObject:]",
	    (t = [TestThread threadWithObject: @"foo"]))

	TEST(@"-[start]", [t start])

	TEST(@"-[join]", [[t join] isEqual: @"success"])

	TEST(@"OFTLSKey's +[tlsKey]", (key = [OFTLSKey tlsKey]))

	TEST(@"+[setObject:forTLSKey:]", [OFThread setObject: @"foo"
						   forTLSKey: key])