objc2_foundation/generated/
NSOperation.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9#[repr(transparent)]
12#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
13pub struct NSOperationQueuePriority(pub NSInteger);
14impl NSOperationQueuePriority {
15 #[doc(alias = "NSOperationQueuePriorityVeryLow")]
16 pub const VeryLow: Self = Self(-8);
17 #[doc(alias = "NSOperationQueuePriorityLow")]
18 pub const Low: Self = Self(-4);
19 #[doc(alias = "NSOperationQueuePriorityNormal")]
20 pub const Normal: Self = Self(0);
21 #[doc(alias = "NSOperationQueuePriorityHigh")]
22 pub const High: Self = Self(4);
23 #[doc(alias = "NSOperationQueuePriorityVeryHigh")]
24 pub const VeryHigh: Self = Self(8);
25}
26
27unsafe impl Encode for NSOperationQueuePriority {
28 const ENCODING: Encoding = NSInteger::ENCODING;
29}
30
31unsafe impl RefEncode for NSOperationQueuePriority {
32 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
33}
34
35extern_class!(
36 #[unsafe(super(NSObject))]
38 #[derive(Debug, PartialEq, Eq, Hash)]
39 pub struct NSOperation;
40);
41
42unsafe impl Send for NSOperation {}
43
44unsafe impl Sync for NSOperation {}
45
46unsafe impl NSObjectProtocol for NSOperation {}
47
48impl NSOperation {
49 extern_methods!(
50 #[unsafe(method(start))]
51 #[unsafe(method_family = none)]
52 pub unsafe fn start(&self);
53
54 #[unsafe(method(main))]
55 #[unsafe(method_family = none)]
56 pub unsafe fn main(&self);
57
58 #[unsafe(method(isCancelled))]
59 #[unsafe(method_family = none)]
60 pub unsafe fn isCancelled(&self) -> bool;
61
62 #[unsafe(method(cancel))]
63 #[unsafe(method_family = none)]
64 pub unsafe fn cancel(&self);
65
66 #[unsafe(method(isExecuting))]
67 #[unsafe(method_family = none)]
68 pub unsafe fn isExecuting(&self) -> bool;
69
70 #[unsafe(method(isFinished))]
71 #[unsafe(method_family = none)]
72 pub unsafe fn isFinished(&self) -> bool;
73
74 #[unsafe(method(isConcurrent))]
75 #[unsafe(method_family = none)]
76 pub unsafe fn isConcurrent(&self) -> bool;
77
78 #[unsafe(method(isAsynchronous))]
79 #[unsafe(method_family = none)]
80 pub unsafe fn isAsynchronous(&self) -> bool;
81
82 #[unsafe(method(isReady))]
83 #[unsafe(method_family = none)]
84 pub unsafe fn isReady(&self) -> bool;
85
86 #[unsafe(method(addDependency:))]
87 #[unsafe(method_family = none)]
88 pub unsafe fn addDependency(&self, op: &NSOperation);
89
90 #[unsafe(method(removeDependency:))]
91 #[unsafe(method_family = none)]
92 pub unsafe fn removeDependency(&self, op: &NSOperation);
93
94 #[cfg(feature = "NSArray")]
95 #[unsafe(method(dependencies))]
96 #[unsafe(method_family = none)]
97 pub unsafe fn dependencies(&self) -> Retained<NSArray<NSOperation>>;
98
99 #[unsafe(method(queuePriority))]
100 #[unsafe(method_family = none)]
101 pub unsafe fn queuePriority(&self) -> NSOperationQueuePriority;
102
103 #[unsafe(method(setQueuePriority:))]
105 #[unsafe(method_family = none)]
106 pub unsafe fn setQueuePriority(&self, queue_priority: NSOperationQueuePriority);
107
108 #[cfg(feature = "block2")]
109 #[unsafe(method(completionBlock))]
110 #[unsafe(method_family = none)]
111 pub unsafe fn completionBlock(&self) -> *mut block2::Block<dyn Fn()>;
112
113 #[cfg(feature = "block2")]
114 #[unsafe(method(setCompletionBlock:))]
116 #[unsafe(method_family = none)]
117 pub unsafe fn setCompletionBlock(&self, completion_block: Option<&block2::Block<dyn Fn()>>);
118
119 #[unsafe(method(waitUntilFinished))]
120 #[unsafe(method_family = none)]
121 pub unsafe fn waitUntilFinished(&self);
122
123 #[deprecated = "Not supported"]
124 #[unsafe(method(threadPriority))]
125 #[unsafe(method_family = none)]
126 pub unsafe fn threadPriority(&self) -> c_double;
127
128 #[deprecated = "Not supported"]
130 #[unsafe(method(setThreadPriority:))]
131 #[unsafe(method_family = none)]
132 pub unsafe fn setThreadPriority(&self, thread_priority: c_double);
133
134 #[cfg(feature = "NSObjCRuntime")]
135 #[unsafe(method(qualityOfService))]
136 #[unsafe(method_family = none)]
137 pub unsafe fn qualityOfService(&self) -> NSQualityOfService;
138
139 #[cfg(feature = "NSObjCRuntime")]
140 #[unsafe(method(setQualityOfService:))]
142 #[unsafe(method_family = none)]
143 pub unsafe fn setQualityOfService(&self, quality_of_service: NSQualityOfService);
144
145 #[cfg(feature = "NSString")]
146 #[unsafe(method(name))]
147 #[unsafe(method_family = none)]
148 pub unsafe fn name(&self) -> Option<Retained<NSString>>;
149
150 #[cfg(feature = "NSString")]
151 #[unsafe(method(setName:))]
153 #[unsafe(method_family = none)]
154 pub unsafe fn setName(&self, name: Option<&NSString>);
155 );
156}
157
158impl NSOperation {
160 extern_methods!(
161 #[unsafe(method(init))]
162 #[unsafe(method_family = init)]
163 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
164
165 #[unsafe(method(new))]
166 #[unsafe(method_family = new)]
167 pub unsafe fn new() -> Retained<Self>;
168 );
169}
170
171extern_class!(
172 #[unsafe(super(NSOperation, NSObject))]
174 #[derive(Debug, PartialEq, Eq, Hash)]
175 pub struct NSBlockOperation;
176);
177
178unsafe impl Send for NSBlockOperation {}
179
180unsafe impl Sync for NSBlockOperation {}
181
182unsafe impl NSObjectProtocol for NSBlockOperation {}
183
184impl NSBlockOperation {
185 extern_methods!(
186 #[cfg(feature = "block2")]
187 #[unsafe(method(blockOperationWithBlock:))]
188 #[unsafe(method_family = none)]
189 pub unsafe fn blockOperationWithBlock(block: &block2::Block<dyn Fn()>) -> Retained<Self>;
190
191 #[cfg(feature = "block2")]
192 #[unsafe(method(addExecutionBlock:))]
193 #[unsafe(method_family = none)]
194 pub unsafe fn addExecutionBlock(&self, block: &block2::Block<dyn Fn()>);
195 );
196}
197
198impl NSBlockOperation {
200 extern_methods!(
201 #[unsafe(method(init))]
202 #[unsafe(method_family = init)]
203 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
204
205 #[unsafe(method(new))]
206 #[unsafe(method_family = new)]
207 pub unsafe fn new() -> Retained<Self>;
208 );
209}
210
211extern_class!(
212 #[unsafe(super(NSOperation, NSObject))]
214 #[derive(Debug, PartialEq, Eq, Hash)]
215 pub struct NSInvocationOperation;
216);
217
218unsafe impl NSObjectProtocol for NSInvocationOperation {}
219
220impl NSInvocationOperation {
221 extern_methods!(
222 #[unsafe(method(initWithTarget:selector:object:))]
223 #[unsafe(method_family = init)]
224 pub unsafe fn initWithTarget_selector_object(
225 this: Allocated<Self>,
226 target: &AnyObject,
227 sel: Sel,
228 arg: Option<&AnyObject>,
229 ) -> Option<Retained<Self>>;
230
231 #[cfg(feature = "NSInvocation")]
232 #[unsafe(method(initWithInvocation:))]
233 #[unsafe(method_family = init)]
234 pub unsafe fn initWithInvocation(
235 this: Allocated<Self>,
236 inv: &NSInvocation,
237 ) -> Retained<Self>;
238
239 #[cfg(feature = "NSInvocation")]
240 #[unsafe(method(invocation))]
241 #[unsafe(method_family = none)]
242 pub unsafe fn invocation(&self) -> Retained<NSInvocation>;
243
244 #[unsafe(method(result))]
245 #[unsafe(method_family = none)]
246 pub unsafe fn result(&self) -> Option<Retained<AnyObject>>;
247 );
248}
249
250impl NSInvocationOperation {
252 extern_methods!(
253 #[unsafe(method(init))]
254 #[unsafe(method_family = init)]
255 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
256
257 #[unsafe(method(new))]
258 #[unsafe(method_family = new)]
259 pub unsafe fn new() -> Retained<Self>;
260 );
261}
262
263extern "C" {
264 #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
266 pub static NSInvocationOperationVoidResultException: &'static NSExceptionName;
267}
268
269extern "C" {
270 #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
272 pub static NSInvocationOperationCancelledException: &'static NSExceptionName;
273}
274
275pub static NSOperationQueueDefaultMaxConcurrentOperationCount: NSInteger = -1;
277
278extern_class!(
279 #[unsafe(super(NSObject))]
281 #[derive(Debug, PartialEq, Eq, Hash)]
282 pub struct NSOperationQueue;
283);
284
285unsafe impl Send for NSOperationQueue {}
286
287unsafe impl Sync for NSOperationQueue {}
288
289unsafe impl NSObjectProtocol for NSOperationQueue {}
290
291#[cfg(feature = "NSProgress")]
292unsafe impl NSProgressReporting for NSOperationQueue {}
293
294impl NSOperationQueue {
295 extern_methods!(
296 #[cfg(feature = "NSProgress")]
297 #[unsafe(method(progress))]
313 #[unsafe(method_family = none)]
314 pub unsafe fn progress(&self) -> Retained<NSProgress>;
315
316 #[unsafe(method(addOperation:))]
317 #[unsafe(method_family = none)]
318 pub unsafe fn addOperation(&self, op: &NSOperation);
319
320 #[cfg(feature = "NSArray")]
321 #[unsafe(method(addOperations:waitUntilFinished:))]
322 #[unsafe(method_family = none)]
323 pub unsafe fn addOperations_waitUntilFinished(
324 &self,
325 ops: &NSArray<NSOperation>,
326 wait: bool,
327 );
328
329 #[cfg(feature = "block2")]
330 #[unsafe(method(addOperationWithBlock:))]
331 #[unsafe(method_family = none)]
332 pub unsafe fn addOperationWithBlock(&self, block: &block2::Block<dyn Fn()>);
333
334 #[cfg(feature = "block2")]
335 #[unsafe(method(addBarrierBlock:))]
341 #[unsafe(method_family = none)]
342 pub unsafe fn addBarrierBlock(&self, barrier: &block2::Block<dyn Fn()>);
343
344 #[unsafe(method(maxConcurrentOperationCount))]
345 #[unsafe(method_family = none)]
346 pub unsafe fn maxConcurrentOperationCount(&self) -> NSInteger;
347
348 #[unsafe(method(setMaxConcurrentOperationCount:))]
350 #[unsafe(method_family = none)]
351 pub unsafe fn setMaxConcurrentOperationCount(
352 &self,
353 max_concurrent_operation_count: NSInteger,
354 );
355
356 #[unsafe(method(isSuspended))]
357 #[unsafe(method_family = none)]
358 pub unsafe fn isSuspended(&self) -> bool;
359
360 #[unsafe(method(setSuspended:))]
362 #[unsafe(method_family = none)]
363 pub unsafe fn setSuspended(&self, suspended: bool);
364
365 #[cfg(feature = "NSString")]
366 #[unsafe(method(name))]
367 #[unsafe(method_family = none)]
368 pub unsafe fn name(&self) -> Option<Retained<NSString>>;
369
370 #[cfg(feature = "NSString")]
371 #[unsafe(method(setName:))]
373 #[unsafe(method_family = none)]
374 pub unsafe fn setName(&self, name: Option<&NSString>);
375
376 #[cfg(feature = "NSObjCRuntime")]
377 #[unsafe(method(qualityOfService))]
378 #[unsafe(method_family = none)]
379 pub unsafe fn qualityOfService(&self) -> NSQualityOfService;
380
381 #[cfg(feature = "NSObjCRuntime")]
382 #[unsafe(method(setQualityOfService:))]
384 #[unsafe(method_family = none)]
385 pub unsafe fn setQualityOfService(&self, quality_of_service: NSQualityOfService);
386
387 #[unsafe(method(cancelAllOperations))]
388 #[unsafe(method_family = none)]
389 pub unsafe fn cancelAllOperations(&self);
390
391 #[unsafe(method(waitUntilAllOperationsAreFinished))]
392 #[unsafe(method_family = none)]
393 pub unsafe fn waitUntilAllOperationsAreFinished(&self);
394
395 #[unsafe(method(currentQueue))]
396 #[unsafe(method_family = none)]
397 pub unsafe fn currentQueue() -> Option<Retained<NSOperationQueue>>;
398
399 #[unsafe(method(mainQueue))]
400 #[unsafe(method_family = none)]
401 pub unsafe fn mainQueue() -> Retained<NSOperationQueue>;
402 );
403}
404
405impl NSOperationQueue {
407 extern_methods!(
408 #[unsafe(method(init))]
409 #[unsafe(method_family = init)]
410 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
411
412 #[unsafe(method(new))]
413 #[unsafe(method_family = new)]
414 pub unsafe fn new() -> Retained<Self>;
415 );
416}
417
418impl NSOperationQueue {
420 extern_methods!(
421 #[cfg(feature = "NSArray")]
422 #[deprecated = "access to operations is inherently a race condition, it should not be used. For barrier style behaviors please use addBarrierBlock: instead"]
423 #[unsafe(method(operations))]
424 #[unsafe(method_family = none)]
425 pub unsafe fn operations(&self) -> Retained<NSArray<NSOperation>>;
426
427 #[deprecated]
428 #[unsafe(method(operationCount))]
429 #[unsafe(method_family = none)]
430 pub unsafe fn operationCount(&self) -> NSUInteger;
431 );
432}