mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
a few queue tests
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37554 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
84425c4a30
commit
09ca29c3fc
1 changed files with 13 additions and 2 deletions
|
@ -51,10 +51,12 @@
|
|||
|
||||
@interface OpFlag : NSOperation
|
||||
{
|
||||
NSThread *thread;
|
||||
BOOL flag;
|
||||
NSOperationQueue *queue;
|
||||
NSThread *thread;
|
||||
BOOL flag;
|
||||
}
|
||||
- (void) main;
|
||||
- (NSOperationQueue*) queue;
|
||||
- (BOOL) ran;
|
||||
- (NSThread*) thread;
|
||||
@end
|
||||
|
@ -63,8 +65,13 @@
|
|||
- (void) main
|
||||
{
|
||||
flag = YES;
|
||||
queue = [NSOperationQueue currentQueue];
|
||||
thread = [NSThread currentThread];
|
||||
}
|
||||
- (NSOperationQueue*) queue
|
||||
{
|
||||
return queue;
|
||||
}
|
||||
- (BOOL) ran
|
||||
{
|
||||
return flag;
|
||||
|
@ -132,6 +139,7 @@ int main()
|
|||
[obj start];
|
||||
PASS(([obj ran] == YES), "operation ran");
|
||||
PASS(([obj thread] == [NSThread currentThread]), "operation ran in this thread");
|
||||
PASS(([obj queue] == [NSOperationQueue mainQueue]), "operation ran in main queue");
|
||||
[obj release];
|
||||
|
||||
// Check that monitoring of another thread works.
|
||||
|
@ -176,11 +184,14 @@ int main()
|
|||
|
||||
obj = [OpFlag new];
|
||||
q = [NSOperationQueue new];
|
||||
PASS(q != [NSOperationQueue mainQueue], "my queue is not main queue");
|
||||
PASS(q != [NSOperationQueue currentQueue], "my queue is not current queue");
|
||||
[cnt reset];
|
||||
[q addOperation: obj];
|
||||
[q waitUntilAllOperationsAreFinished];
|
||||
PASS(([obj ran] == YES), "operation ran");
|
||||
PASS(([obj thread] != [NSThread currentThread]), "operation ran in other thread");
|
||||
PASS(([obj queue] == q), "operation ran in my queue");
|
||||
|
||||
PASS(([cnt count] == 0), "thread did not exit immediately");
|
||||
[obj release];
|
||||
|
|
Loading…
Reference in a new issue