mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-29 16:01:38 +00:00
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:
parent
6bf1893998
commit
a07207b11e
3 changed files with 64 additions and 1 deletions
|
@ -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
50
Testing/thread.m
Normal 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;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue