Oolite
Loading...
Searching...
No Matches
OONSOperation.h
Go to the documentation of this file.
1/*
2
3NSOperationQueue was introduced in Mac OS X 10.5 and GNUstep 0.19.x.
4
5This header helps us use it if it's available at runtime without requiring
6it (see OOAsyncWorkManager.m).
7-- Ahruman 2009-09-04
8
9
10Copyright (C) 2009-2013 Jens Ayton
11
12Permission is hereby granted, free of charge, to any person obtaining a copy
13of this software and associated documentation files (the "Software"), to deal
14in the Software without restriction, including without limitation the rights
15to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16copies of the Software, and to permit persons to whom the Software is
17furnished to do so, subject to the following conditions:
18
19The above copyright notice and this permission notice shall be included in all
20copies or substantial portions of the Software.
21
22THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28SOFTWARE.
29
30*/
31
32#ifndef OO_HAVE_NSOPERATION
33#if OOLITE_MAC_OS_X
34#define OO_HAVE_NSOPERATION (1)
35#elif OOLITE_GNUSTEP
36// #define OO_HAVE_NSOPERATION OS_API_VERSION(100500, GS_API_LATEST)
37// GNUstep (even current trunk - 1.21 @ 2010.06.06) only contains an
38// incomplete implementation of NSOperation. Namely, it's missing
39// NSInvocationOperation which is used in OOAsyncWorkManager.m
40#define OO_HAVE_NSOPERATION (0)
41#endif
42#endif
43
44#ifndef OO_ALLOW_NSOPERATION
45#define OO_ALLOW_NSOPERATION 1
46#endif
47
48#if OO_ALLOW_NSOPERATION
49#if !OO_HAVE_NSOPERATION
50
52
53#define OONSOperationQueue id
54#define OONSOperation id
55#define OONSInvocationOperation id
56
57/* NOTE: if OO_HAVE_NSOPERATION, these will compile to class names, which are
58 not values. If you want an actual Class object, use [OONSOperationClass() class].
59*/
63
65{
66 return NSClassFromString(@"NSOperationQueue");
67}
68
70{
71 return NSClassFromString(@"NSOperation");
72}
73
75{
76 return NSClassFromString(@"NSInvocationOperation");
77}
78
79@class NSOperationQueue;
80@class NSOperation;
81@class NSInvocationOperation;
82
83enum {
89};
90
91/* These classes are (deliberately) not implemented. Their declarations exist
92 only so that the type system will know about the methods when they're used
93 on id variables.
94*/
95
97
98- (void)start;
99- (void)main;
100
102- (void)cancel;
103
106
108
109- (BOOL)isReady;
110
111- (void)addDependency:(NSOperation*)op;
112- (void)removeDependency:(NSOperation*)op;
113
114- (NSArray*)dependencies;
115
116- (NSInteger)queuePriority;
117- (void)setQueuePriority:(NSInteger)p;
118
119@end
120
122
123- (id)initWithTarget:(id)target selector:(SEL)sel object:(id)arg;
124- (id)initWithInvocation:(NSInvocation*)inv;
125
126- (NSInvocation*)invocation;
127
128- (id)result;
129
130@end
131
133
134- (void)addOperation:(NSOperation*)op;
135
136- (NSArray*)operations;
137
139- (void)setMaxConcurrentOperationCount:(NSInteger)cnt;
140
141- (void)setSuspended:(BOOL)b;
143
145
147
148@end
149
150#else
151
152#define OONSOperationQueue NSOperationQueue*
153#define OONSOperation NSOperation*
154#define OONSInvocationOperation NSInvocationOperation*
155
156#define OONSOperationQueueClass() NSOperationQueue
157#define OONSOperationClass() NSOperation
158#define OONSInvocationOperationClass() NSInvocationOperation
159
160enum {
161 OONSOperationQueuePriorityVeryLow = NSOperationQueuePriorityVeryLow,
162 OONSOperationQueuePriorityLow = NSOperationQueuePriorityLow,
163 OONSOperationQueuePriorityNormal = NSOperationQueuePriorityNormal,
164 OONSOperationQueuePriorityHigh = NSOperationQueuePriorityHigh,
165 OONSOperationQueuePriorityVeryHigh = NSOperationQueuePriorityVeryHigh
166};
167
168#endif
169#endif
#define OOINLINE
#define PURE_FUNC
OOINLINE Class OONSOperationQueueClass() PURE_FUNC
@ OONSOperationQueuePriorityVeryHigh
@ OONSOperationQueuePriorityLow
@ OONSOperationQueuePriorityHigh
@ OONSOperationQueuePriorityNormal
@ OONSOperationQueuePriorityVeryLow
OOINLINE Class OONSOperationClass() PURE_FUNC
OOINLINE Class OONSInvocationOperationClass() PURE_FUNC
NSArray * dependencies()
NSInteger queuePriority()
void waitUntilAllOperationsAreFinished()
NSInteger maxConcurrentOperationCount()