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
46extern_conformance!(
47 unsafe impl NSObjectProtocol for NSOperation {}
48);
49
50impl NSOperation {
51 extern_methods!(
52 #[unsafe(method(start))]
53 #[unsafe(method_family = none)]
54 pub fn start(&self);
55
56 #[unsafe(method(main))]
57 #[unsafe(method_family = none)]
58 pub fn main(&self);
59
60 #[unsafe(method(isCancelled))]
61 #[unsafe(method_family = none)]
62 pub fn isCancelled(&self) -> bool;
63
64 #[unsafe(method(cancel))]
65 #[unsafe(method_family = none)]
66 pub fn cancel(&self);
67
68 #[unsafe(method(isExecuting))]
69 #[unsafe(method_family = none)]
70 pub fn isExecuting(&self) -> bool;
71
72 #[unsafe(method(isFinished))]
73 #[unsafe(method_family = none)]
74 pub fn isFinished(&self) -> bool;
75
76 #[unsafe(method(isConcurrent))]
77 #[unsafe(method_family = none)]
78 pub fn isConcurrent(&self) -> bool;
79
80 #[unsafe(method(isAsynchronous))]
81 #[unsafe(method_family = none)]
82 pub fn isAsynchronous(&self) -> bool;
83
84 #[unsafe(method(isReady))]
85 #[unsafe(method_family = none)]
86 pub fn isReady(&self) -> bool;
87
88 #[unsafe(method(addDependency:))]
89 #[unsafe(method_family = none)]
90 pub fn addDependency(&self, op: &NSOperation);
91
92 #[unsafe(method(removeDependency:))]
93 #[unsafe(method_family = none)]
94 pub fn removeDependency(&self, op: &NSOperation);
95
96 #[cfg(feature = "NSArray")]
97 #[unsafe(method(dependencies))]
98 #[unsafe(method_family = none)]
99 pub fn dependencies(&self) -> Retained<NSArray<NSOperation>>;
100
101 #[unsafe(method(queuePriority))]
102 #[unsafe(method_family = none)]
103 pub fn queuePriority(&self) -> NSOperationQueuePriority;
104
105 #[unsafe(method(setQueuePriority:))]
107 #[unsafe(method_family = none)]
108 pub fn setQueuePriority(&self, queue_priority: NSOperationQueuePriority);
109
110 #[cfg(feature = "block2")]
111 #[unsafe(method(completionBlock))]
115 #[unsafe(method_family = none)]
116 pub unsafe fn completionBlock(&self) -> *mut block2::DynBlock<dyn Fn()>;
117
118 #[cfg(feature = "block2")]
119 #[unsafe(method(setCompletionBlock:))]
127 #[unsafe(method_family = none)]
128 pub unsafe fn setCompletionBlock(
129 &self,
130 completion_block: Option<&block2::DynBlock<dyn Fn()>>,
131 );
132
133 #[unsafe(method(waitUntilFinished))]
134 #[unsafe(method_family = none)]
135 pub fn waitUntilFinished(&self);
136
137 #[deprecated = "Not supported"]
138 #[unsafe(method(threadPriority))]
139 #[unsafe(method_family = none)]
140 pub fn threadPriority(&self) -> c_double;
141
142 #[deprecated = "Not supported"]
144 #[unsafe(method(setThreadPriority:))]
145 #[unsafe(method_family = none)]
146 pub fn setThreadPriority(&self, thread_priority: c_double);
147
148 #[cfg(feature = "NSObjCRuntime")]
149 #[unsafe(method(qualityOfService))]
150 #[unsafe(method_family = none)]
151 pub fn qualityOfService(&self) -> NSQualityOfService;
152
153 #[cfg(feature = "NSObjCRuntime")]
154 #[unsafe(method(setQualityOfService:))]
156 #[unsafe(method_family = none)]
157 pub fn setQualityOfService(&self, quality_of_service: NSQualityOfService);
158
159 #[cfg(feature = "NSString")]
160 #[unsafe(method(name))]
161 #[unsafe(method_family = none)]
162 pub fn name(&self) -> Option<Retained<NSString>>;
163
164 #[cfg(feature = "NSString")]
165 #[unsafe(method(setName:))]
169 #[unsafe(method_family = none)]
170 pub fn setName(&self, name: Option<&NSString>);
171 );
172}
173
174impl NSOperation {
176 extern_methods!(
177 #[unsafe(method(init))]
178 #[unsafe(method_family = init)]
179 pub fn init(this: Allocated<Self>) -> Retained<Self>;
180
181 #[unsafe(method(new))]
182 #[unsafe(method_family = new)]
183 pub fn new() -> Retained<Self>;
184 );
185}
186
187impl DefaultRetained for NSOperation {
188 #[inline]
189 fn default_retained() -> Retained<Self> {
190 Self::new()
191 }
192}
193
194extern_class!(
195 #[unsafe(super(NSOperation, NSObject))]
197 #[derive(Debug, PartialEq, Eq, Hash)]
198 pub struct NSBlockOperation;
199);
200
201unsafe impl Send for NSBlockOperation {}
202
203unsafe impl Sync for NSBlockOperation {}
204
205extern_conformance!(
206 unsafe impl NSObjectProtocol for NSBlockOperation {}
207);
208
209impl NSBlockOperation {
210 extern_methods!(
211 #[cfg(feature = "block2")]
212 #[unsafe(method(blockOperationWithBlock:))]
216 #[unsafe(method_family = none)]
217 pub unsafe fn blockOperationWithBlock(block: &block2::DynBlock<dyn Fn()>)
218 -> Retained<Self>;
219
220 #[cfg(feature = "block2")]
221 #[unsafe(method(addExecutionBlock:))]
225 #[unsafe(method_family = none)]
226 pub unsafe fn addExecutionBlock(&self, block: &block2::DynBlock<dyn Fn()>);
227 );
228}
229
230impl NSBlockOperation {
232 extern_methods!(
233 #[unsafe(method(init))]
234 #[unsafe(method_family = init)]
235 pub fn init(this: Allocated<Self>) -> Retained<Self>;
236
237 #[unsafe(method(new))]
238 #[unsafe(method_family = new)]
239 pub fn new() -> Retained<Self>;
240 );
241}
242
243impl DefaultRetained for NSBlockOperation {
244 #[inline]
245 fn default_retained() -> Retained<Self> {
246 Self::new()
247 }
248}
249
250extern_class!(
251 #[unsafe(super(NSOperation, NSObject))]
253 #[derive(Debug, PartialEq, Eq, Hash)]
254 pub struct NSInvocationOperation;
255);
256
257extern_conformance!(
258 unsafe impl NSObjectProtocol for NSInvocationOperation {}
259);
260
261impl NSInvocationOperation {
262 extern_methods!(
263 #[unsafe(method(initWithTarget:selector:object:))]
269 #[unsafe(method_family = init)]
270 pub unsafe fn initWithTarget_selector_object(
271 this: Allocated<Self>,
272 target: &AnyObject,
273 sel: Sel,
274 arg: Option<&AnyObject>,
275 ) -> Option<Retained<Self>>;
276
277 #[cfg(feature = "NSInvocation")]
278 #[unsafe(method(initWithInvocation:))]
279 #[unsafe(method_family = init)]
280 pub unsafe fn initWithInvocation(
281 this: Allocated<Self>,
282 inv: &NSInvocation,
283 ) -> Retained<Self>;
284
285 #[cfg(feature = "NSInvocation")]
286 #[unsafe(method(invocation))]
287 #[unsafe(method_family = none)]
288 pub unsafe fn invocation(&self) -> Retained<NSInvocation>;
289
290 #[unsafe(method(result))]
291 #[unsafe(method_family = none)]
292 pub fn result(&self) -> Option<Retained<AnyObject>>;
293 );
294}
295
296impl NSInvocationOperation {
298 extern_methods!(
299 #[unsafe(method(init))]
300 #[unsafe(method_family = init)]
301 pub fn init(this: Allocated<Self>) -> Retained<Self>;
302
303 #[unsafe(method(new))]
304 #[unsafe(method_family = new)]
305 pub fn new() -> Retained<Self>;
306 );
307}
308
309impl DefaultRetained for NSInvocationOperation {
310 #[inline]
311 fn default_retained() -> Retained<Self> {
312 Self::new()
313 }
314}
315
316extern "C" {
317 #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
319 pub static NSInvocationOperationVoidResultException: &'static NSExceptionName;
320}
321
322extern "C" {
323 #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
325 pub static NSInvocationOperationCancelledException: &'static NSExceptionName;
326}
327
328pub static NSOperationQueueDefaultMaxConcurrentOperationCount: NSInteger = -1;
330
331extern_class!(
332 #[unsafe(super(NSObject))]
334 #[derive(Debug, PartialEq, Eq, Hash)]
335 pub struct NSOperationQueue;
336);
337
338unsafe impl Send for NSOperationQueue {}
339
340unsafe impl Sync for NSOperationQueue {}
341
342extern_conformance!(
343 unsafe impl NSObjectProtocol for NSOperationQueue {}
344);
345
346#[cfg(feature = "NSProgress")]
347extern_conformance!(
348 unsafe impl NSProgressReporting for NSOperationQueue {}
349);
350
351impl NSOperationQueue {
352 extern_methods!(
353 #[cfg(feature = "NSProgress")]
354 #[unsafe(method(progress))]
370 #[unsafe(method_family = none)]
371 pub fn progress(&self) -> Retained<NSProgress>;
372
373 #[unsafe(method(addOperation:))]
374 #[unsafe(method_family = none)]
375 pub fn addOperation(&self, op: &NSOperation);
376
377 #[cfg(feature = "NSArray")]
378 #[unsafe(method(addOperations:waitUntilFinished:))]
379 #[unsafe(method_family = none)]
380 pub fn addOperations_waitUntilFinished(&self, ops: &NSArray<NSOperation>, wait: bool);
381
382 #[cfg(feature = "block2")]
383 #[unsafe(method(addOperationWithBlock:))]
387 #[unsafe(method_family = none)]
388 pub unsafe fn addOperationWithBlock(&self, block: &block2::DynBlock<dyn Fn()>);
389
390 #[cfg(feature = "block2")]
391 #[unsafe(method(addBarrierBlock:))]
401 #[unsafe(method_family = none)]
402 pub unsafe fn addBarrierBlock(&self, barrier: &block2::DynBlock<dyn Fn()>);
403
404 #[unsafe(method(maxConcurrentOperationCount))]
405 #[unsafe(method_family = none)]
406 pub fn maxConcurrentOperationCount(&self) -> NSInteger;
407
408 #[unsafe(method(setMaxConcurrentOperationCount:))]
410 #[unsafe(method_family = none)]
411 pub fn setMaxConcurrentOperationCount(&self, max_concurrent_operation_count: NSInteger);
412
413 #[unsafe(method(isSuspended))]
414 #[unsafe(method_family = none)]
415 pub fn isSuspended(&self) -> bool;
416
417 #[unsafe(method(setSuspended:))]
419 #[unsafe(method_family = none)]
420 pub fn setSuspended(&self, suspended: bool);
421
422 #[cfg(feature = "NSString")]
423 #[unsafe(method(name))]
424 #[unsafe(method_family = none)]
425 pub fn name(&self) -> Option<Retained<NSString>>;
426
427 #[cfg(feature = "NSString")]
428 #[unsafe(method(setName:))]
432 #[unsafe(method_family = none)]
433 pub fn setName(&self, name: Option<&NSString>);
434
435 #[cfg(feature = "NSObjCRuntime")]
436 #[unsafe(method(qualityOfService))]
437 #[unsafe(method_family = none)]
438 pub fn qualityOfService(&self) -> NSQualityOfService;
439
440 #[cfg(feature = "NSObjCRuntime")]
441 #[unsafe(method(setQualityOfService:))]
443 #[unsafe(method_family = none)]
444 pub fn setQualityOfService(&self, quality_of_service: NSQualityOfService);
445
446 #[unsafe(method(cancelAllOperations))]
447 #[unsafe(method_family = none)]
448 pub fn cancelAllOperations(&self);
449
450 #[unsafe(method(waitUntilAllOperationsAreFinished))]
451 #[unsafe(method_family = none)]
452 pub fn waitUntilAllOperationsAreFinished(&self);
453
454 #[unsafe(method(currentQueue))]
455 #[unsafe(method_family = none)]
456 pub fn currentQueue() -> Option<Retained<NSOperationQueue>>;
457
458 #[unsafe(method(mainQueue))]
459 #[unsafe(method_family = none)]
460 pub fn mainQueue() -> Retained<NSOperationQueue>;
461 );
462}
463
464impl NSOperationQueue {
466 extern_methods!(
467 #[unsafe(method(init))]
468 #[unsafe(method_family = init)]
469 pub fn init(this: Allocated<Self>) -> Retained<Self>;
470
471 #[unsafe(method(new))]
472 #[unsafe(method_family = new)]
473 pub fn new() -> Retained<Self>;
474 );
475}
476
477impl DefaultRetained for NSOperationQueue {
478 #[inline]
479 fn default_retained() -> Retained<Self> {
480 Self::new()
481 }
482}
483
484impl NSOperationQueue {
486 extern_methods!(
487 #[cfg(feature = "NSArray")]
488 #[deprecated = "access to operations is inherently a race condition, it should not be used. For barrier style behaviors please use addBarrierBlock: instead"]
489 #[unsafe(method(operations))]
490 #[unsafe(method_family = none)]
491 pub fn operations(&self) -> Retained<NSArray<NSOperation>>;
492
493 #[deprecated]
494 #[unsafe(method(operationCount))]
495 #[unsafe(method_family = none)]
496 pub fn operationCount(&self) -> NSUInteger;
497 );
498}