simplifications and bugfixes of perform code.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14909 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2002-11-03 15:52:54 +00:00
parent 4200db20e9
commit aa8d9f3fb8
3 changed files with 64 additions and 1 deletions

View file

@ -1,3 +1,14 @@
2002-11-03 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSRunLoop.m: Revert to remove unneeded notification setup.
* Source/NSThread.m: Rewrite pierres changes, scrapping all
conditionally compiled code that would never be used, rewriting
unix specific stuff (so it might run under windoze ... not yet tested)
removed unnecessary code and simplified, etc etc.
Fixed bugs in usage of condition locks so it actually works.
* Testing/thread.m: New test to try out
performSelectorOnMainThread:withObject:waitUntilDone:modes:
2002-11-02 Pierre-Yves Rivaille <pyrivail@ens-lyon.fr>
* Source/NSRunLoop.m ([NSRunLoop -init]): ask to be informed about
@ -7,7 +18,7 @@
class.
([NSRunLoop -_willBecomeMultiThreaded:]): new method, sets up the
lock, the socket and new run loop watcher that'll listen on the socket.
([NSObject -performSelectorOnMainThread:withObject:waitUntilDone:modes:]):
[NSObject -performSelectorOnMainThread:withObject:waitUntilDone:modes:]):
modified to use the previous changes.
2002-11-01 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -72,6 +72,7 @@ TEST_TOOL_NAME = \
nstimezone \
release \
string \
thread \
thread-except \
values \
@ -116,6 +117,7 @@ prepend_OBJC_FILES = prepend.m
release_OBJC_FILES = release.m
string_OBJC_FILES = string.m
testtool_OBJC_FILES = testtool.m
thread_OBJC_FILES = thread.m
thread-except_OBJC_FILES = thread-except.m
values_OBJC_FILES = values.m

50
Testing/thread.m Normal file
View file

@ -0,0 +1,50 @@
#import <Foundation/Foundation.h>
@interface XX : NSObject
- (void) fire;
- (void) setup;
@end
@implementation XX
- (void) fire
{
NSLog(@"Got here");
}
- (void) setup
{
CREATE_AUTORELEASE_POOL(arp);
NSLog(@"Setup1");
[NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: 1.0]];
NSLog(@"Setup2");
[self performSelectorOnMainThread: @selector(fire)
withObject: nil
waitUntilDone: NO];
NSLog(@"Done perform no wait.");
[NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: 1.0]];
NSLog(@"Setup3");
[self performSelectorOnMainThread: @selector(fire)
withObject: nil
waitUntilDone: YES];
NSLog(@"Done perform with wait.");
RELEASE(arp);
[NSThread exit];
}
@end
int main(int argc, char **argv, char **env)
{
id arp = [NSAutoreleasePool new];
NSLog(@"Start in main");
[NSThread detachNewThreadSelector: @selector(setup)
toTarget: [XX new]
withObject: nil];
[[NSRunLoop currentRunLoop] runUntilDate:
[NSDate dateWithTimeIntervalSinceNow: 10.0]];
NSLog(@"Done main thread");
return 0;
}