Oolite 1.91.0.7645-241119-222d325
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
33#ifndef OO_HAVE_NSOPERATION
34 #if OOLITE_MAC_OS_X
35 #define OO_HAVE_NSOPERATION (1)
36 #elif OOLITE_GNUSTEP
37// #define OO_HAVE_NSOPERATION OOLITE_GNUSTEP_1_20 && OS_API_VERSION(100500, GS_API_LATEST)
38 // GNUstep (even current trunk - 1.21 @ 2010.06.06) only contains an
39 // incomplete implementation of NSOperation. Namely, it's missing
40 // NSInvocationOperation which is used in OOAsyncWorkManager.m
41 #define OO_HAVE_NSOPERATION (0)
42 #endif
43#endif
44
45#ifndef OO_ALLOW_NSOPERATION
46#define OO_ALLOW_NSOPERATION 1
47#endif
48
49
50#if OO_ALLOW_NSOPERATION
51#if !OO_HAVE_NSOPERATION
52
54
55#define OONSOperationQueue id
56#define OONSOperation id
57#define OONSInvocationOperation id
58
59/* NOTE: if OO_HAVE_NSOPERATION, these will compile to class names, which are
60 not values. If you want an actual Class object, use [OONSOperationClass() class].
61*/
65
67{
68 return NSClassFromString(@"NSOperationQueue");
69}
70
72{
73 return NSClassFromString(@"NSOperation");
74}
75
76
78{
79 return NSClassFromString(@"NSInvocationOperation");
80}
81
82
83@class NSOperationQueue;
84@class NSOperation;
85@class NSInvocationOperation;
86
87
88enum {
94};
95
96
97/* These classes are (deliberately) not implemented. Their declarations exist
98 only so that the type system will know about the methods when they're used
99 on id variables.
100*/
101
103
104- (void) start;
105- (void) main;
106
107- (BOOL) isCancelled;
108- (void) cancel;
109
110- (BOOL) isExecuting;
111- (BOOL) isFinished;
112
113- (BOOL) isConcurrent;
114
115- (BOOL) isReady;
116
117- (void) addDependency:(NSOperation *)op;
118- (void) removeDependency:(NSOperation *)op;
119
120- (NSArray *) dependencies;
121
122- (NSInteger) queuePriority;
123- (void) setQueuePriority:(NSInteger)p;
124
125@end
126
127
129
130- (id) initWithTarget:(id)target selector:(SEL)sel object:(id)arg;
131- (id) initWithInvocation:(NSInvocation *)inv;
132
133- (NSInvocation *) invocation;
134
135- (id) result;
136
137@end
138
139
141
142- (void) addOperation:(NSOperation *)op;
143
144- (NSArray *) operations;
145
146- (NSInteger) maxConcurrentOperationCount;
147- (void) setMaxConcurrentOperationCount:(NSInteger)cnt;
148
149- (void) setSuspended:(BOOL)b;
150- (BOOL) isSuspended;
151
152- (void) cancelAllOperations;
153
155
156@end
157
158#else
159
160#define OONSOperationQueue NSOperationQueue *
161#define OONSOperation NSOperation *
162#define OONSInvocationOperation NSInvocationOperation *
163
164#define OONSOperationQueueClass() NSOperationQueue
165#define OONSOperationClass() NSOperation
166#define OONSInvocationOperationClass() NSInvocationOperation
167
168
169enum {
170 OONSOperationQueuePriorityVeryLow = NSOperationQueuePriorityVeryLow,
171 OONSOperationQueuePriorityLow = NSOperationQueuePriorityLow,
172 OONSOperationQueuePriorityNormal = NSOperationQueuePriorityNormal,
173 OONSOperationQueuePriorityHigh = NSOperationQueuePriorityHigh,
174 OONSOperationQueuePriorityVeryHigh = NSOperationQueuePriorityVeryHigh
175};
176
177#endif
178#endif
#define OOINLINE
#define PURE_FUNC
@ OONSOperationQueuePriorityVeryHigh
@ OONSOperationQueuePriorityLow
@ OONSOperationQueuePriorityHigh
@ OONSOperationQueuePriorityNormal
@ OONSOperationQueuePriorityVeryLow
OOINLINE Class OONSOperationQueueClass() PURE_FUNC
OOINLINE Class OONSOperationClass() PURE_FUNC
OOINLINE Class OONSInvocationOperationClass() PURE_FUNC
int main(int argc, const char *argv[])
Definition main.m:18
NSArray * dependencies()
NSInteger queuePriority()
void waitUntilAllOperationsAreFinished()
NSInteger maxConcurrentOperationCount()