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 unsafe fn start(&self);
55
56 #[unsafe(method(main))]
57 #[unsafe(method_family = none)]
58 pub unsafe fn main(&self);
59
60 #[unsafe(method(isCancelled))]
61 #[unsafe(method_family = none)]
62 pub unsafe fn isCancelled(&self) -> bool;
63
64 #[unsafe(method(cancel))]
65 #[unsafe(method_family = none)]
66 pub unsafe fn cancel(&self);
67
68 #[unsafe(method(isExecuting))]
69 #[unsafe(method_family = none)]
70 pub unsafe fn isExecuting(&self) -> bool;
71
72 #[unsafe(method(isFinished))]
73 #[unsafe(method_family = none)]
74 pub unsafe fn isFinished(&self) -> bool;
75
76 #[unsafe(method(isConcurrent))]
77 #[unsafe(method_family = none)]
78 pub unsafe fn isConcurrent(&self) -> bool;
79
80 #[unsafe(method(isAsynchronous))]
81 #[unsafe(method_family = none)]
82 pub unsafe fn isAsynchronous(&self) -> bool;
83
84 #[unsafe(method(isReady))]
85 #[unsafe(method_family = none)]
86 pub unsafe fn isReady(&self) -> bool;
87
88 #[unsafe(method(addDependency:))]
89 #[unsafe(method_family = none)]
90 pub unsafe fn addDependency(&self, op: &NSOperation);
91
92 #[unsafe(method(removeDependency:))]
93 #[unsafe(method_family = none)]
94 pub unsafe fn removeDependency(&self, op: &NSOperation);
95
96 #[cfg(feature = "NSArray")]
97 #[unsafe(method(dependencies))]
98 #[unsafe(method_family = none)]
99 pub unsafe fn dependencies(&self) -> Retained<NSArray<NSOperation>>;
100
101 #[unsafe(method(queuePriority))]
102 #[unsafe(method_family = none)]
103 pub unsafe fn queuePriority(&self) -> NSOperationQueuePriority;
104
105 #[unsafe(method(setQueuePriority:))]
107 #[unsafe(method_family = none)]
108 pub unsafe fn setQueuePriority(&self, queue_priority: NSOperationQueuePriority);
109
110 #[cfg(feature = "block2")]
111 #[unsafe(method(completionBlock))]
112 #[unsafe(method_family = none)]
113 pub unsafe fn completionBlock(&self) -> *mut block2::DynBlock<dyn Fn()>;
114
115 #[cfg(feature = "block2")]
116 #[unsafe(method(setCompletionBlock:))]
118 #[unsafe(method_family = none)]
119 pub unsafe fn setCompletionBlock(
120 &self,
121 completion_block: Option<&block2::DynBlock<dyn Fn()>>,
122 );
123
124 #[unsafe(method(waitUntilFinished))]
125 #[unsafe(method_family = none)]
126 pub unsafe fn waitUntilFinished(&self);
127
128 #[deprecated = "Not supported"]
129 #[unsafe(method(threadPriority))]
130 #[unsafe(method_family = none)]
131 pub unsafe fn threadPriority(&self) -> c_double;
132
133 #[deprecated = "Not supported"]
135 #[unsafe(method(setThreadPriority:))]
136 #[unsafe(method_family = none)]
137 pub unsafe fn setThreadPriority(&self, thread_priority: c_double);
138
139 #[cfg(feature = "NSObjCRuntime")]
140 #[unsafe(method(qualityOfService))]
141 #[unsafe(method_family = none)]
142 pub unsafe fn qualityOfService(&self) -> NSQualityOfService;
143
144 #[cfg(feature = "NSObjCRuntime")]
145 #[unsafe(method(setQualityOfService:))]
147 #[unsafe(method_family = none)]
148 pub unsafe fn setQualityOfService(&self, quality_of_service: NSQualityOfService);
149
150 #[cfg(feature = "NSString")]
151 #[unsafe(method(name))]
152 #[unsafe(method_family = none)]
153 pub unsafe fn name(&self) -> Option<Retained<NSString>>;
154
155 #[cfg(feature = "NSString")]
156 #[unsafe(method(setName:))]
158 #[unsafe(method_family = none)]
159 pub unsafe fn setName(&self, name: Option<&NSString>);
160 );
161}
162
163impl NSOperation {
165 extern_methods!(
166 #[unsafe(method(init))]
167 #[unsafe(method_family = init)]
168 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
169
170 #[unsafe(method(new))]
171 #[unsafe(method_family = new)]
172 pub unsafe fn new() -> Retained<Self>;
173 );
174}
175
176extern_class!(
177 #[unsafe(super(NSOperation, NSObject))]
179 #[derive(Debug, PartialEq, Eq, Hash)]
180 pub struct NSBlockOperation;
181);
182
183unsafe impl Send for NSBlockOperation {}
184
185unsafe impl Sync for NSBlockOperation {}
186
187extern_conformance!(
188 unsafe impl NSObjectProtocol for NSBlockOperation {}
189);
190
191impl NSBlockOperation {
192 extern_methods!(
193 #[cfg(feature = "block2")]
194 #[unsafe(method(blockOperationWithBlock:))]
195 #[unsafe(method_family = none)]
196 pub unsafe fn blockOperationWithBlock(block: &block2::DynBlock<dyn Fn()>)
197 -> Retained<Self>;
198
199 #[cfg(feature = "block2")]
200 #[unsafe(method(addExecutionBlock:))]
201 #[unsafe(method_family = none)]
202 pub unsafe fn addExecutionBlock(&self, block: &block2::DynBlock<dyn Fn()>);
203 );
204}
205
206impl NSBlockOperation {
208 extern_methods!(
209 #[unsafe(method(init))]
210 #[unsafe(method_family = init)]
211 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
212
213 #[unsafe(method(new))]
214 #[unsafe(method_family = new)]
215 pub unsafe fn new() -> Retained<Self>;
216 );
217}
218
219extern_class!(
220 #[unsafe(super(NSOperation, NSObject))]
222 #[derive(Debug, PartialEq, Eq, Hash)]
223 pub struct NSInvocationOperation;
224);
225
226extern_conformance!(
227 unsafe impl NSObjectProtocol for NSInvocationOperation {}
228);
229
230impl NSInvocationOperation {
231 extern_methods!(
232 #[unsafe(method(initWithTarget:selector:object:))]
233 #[unsafe(method_family = init)]
234 pub unsafe fn initWithTarget_selector_object(
235 this: Allocated<Self>,
236 target: &AnyObject,
237 sel: Sel,
238 arg: Option<&AnyObject>,
239 ) -> Option<Retained<Self>>;
240
241 #[cfg(feature = "NSInvocation")]
242 #[unsafe(method(initWithInvocation:))]
243 #[unsafe(method_family = init)]
244 pub unsafe fn initWithInvocation(
245 this: Allocated<Self>,
246 inv: &NSInvocation,
247 ) -> Retained<Self>;
248
249 #[cfg(feature = "NSInvocation")]
250 #[unsafe(method(invocation))]
251 #[unsafe(method_family = none)]
252 pub unsafe fn invocation(&self) -> Retained<NSInvocation>;
253
254 #[unsafe(method(result))]
255 #[unsafe(method_family = none)]
256 pub unsafe fn result(&self) -> Option<Retained<AnyObject>>;
257 );
258}
259
260impl NSInvocationOperation {
262 extern_methods!(
263 #[unsafe(method(init))]
264 #[unsafe(method_family = init)]
265 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
266
267 #[unsafe(method(new))]
268 #[unsafe(method_family = new)]
269 pub unsafe fn new() -> Retained<Self>;
270 );
271}
272
273extern "C" {
274 #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
276 pub static NSInvocationOperationVoidResultException: &'static NSExceptionName;
277}
278
279extern "C" {
280 #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
282 pub static NSInvocationOperationCancelledException: &'static NSExceptionName;
283}
284
285pub static NSOperationQueueDefaultMaxConcurrentOperationCount: NSInteger = -1;
287
288extern_class!(
289 #[unsafe(super(NSObject))]
291 #[derive(Debug, PartialEq, Eq, Hash)]
292 pub struct NSOperationQueue;
293);
294
295unsafe impl Send for NSOperationQueue {}
296
297unsafe impl Sync for NSOperationQueue {}
298
299extern_conformance!(
300 unsafe impl NSObjectProtocol for NSOperationQueue {}
301);
302
303#[cfg(feature = "NSProgress")]
304extern_conformance!(
305 unsafe impl NSProgressReporting for NSOperationQueue {}
306);
307
308impl NSOperationQueue {
309 extern_methods!(
310 #[cfg(feature = "NSProgress")]
311 #[unsafe(method(progress))]
327 #[unsafe(method_family = none)]
328 pub unsafe fn progress(&self) -> Retained<NSProgress>;
329
330 #[unsafe(method(addOperation:))]
331 #[unsafe(method_family = none)]
332 pub unsafe fn addOperation(&self, op: &NSOperation);
333
334 #[cfg(feature = "NSArray")]
335 #[unsafe(method(addOperations:waitUntilFinished:))]
336 #[unsafe(method_family = none)]
337 pub unsafe fn addOperations_waitUntilFinished(
338 &self,
339 ops: &NSArray<NSOperation>,
340 wait: bool,
341 );
342
343 #[cfg(feature = "block2")]
344 #[unsafe(method(addOperationWithBlock:))]
345 #[unsafe(method_family = none)]
346 pub unsafe fn addOperationWithBlock(&self, block: &block2::DynBlock<dyn Fn()>);
347
348 #[cfg(feature = "block2")]
349 #[unsafe(method(addBarrierBlock:))]
355 #[unsafe(method_family = none)]
356 pub unsafe fn addBarrierBlock(&self, barrier: &block2::DynBlock<dyn Fn()>);
357
358 #[unsafe(method(maxConcurrentOperationCount))]
359 #[unsafe(method_family = none)]
360 pub unsafe fn maxConcurrentOperationCount(&self) -> NSInteger;
361
362 #[unsafe(method(setMaxConcurrentOperationCount:))]
364 #[unsafe(method_family = none)]
365 pub unsafe fn setMaxConcurrentOperationCount(
366 &self,
367 max_concurrent_operation_count: NSInteger,
368 );
369
370 #[unsafe(method(isSuspended))]
371 #[unsafe(method_family = none)]
372 pub unsafe fn isSuspended(&self) -> bool;
373
374 #[unsafe(method(setSuspended:))]
376 #[unsafe(method_family = none)]
377 pub unsafe fn setSuspended(&self, suspended: bool);
378
379 #[cfg(feature = "NSString")]
380 #[unsafe(method(name))]
381 #[unsafe(method_family = none)]
382 pub unsafe fn name(&self) -> Option<Retained<NSString>>;
383
384 #[cfg(feature = "NSString")]
385 #[unsafe(method(setName:))]
387 #[unsafe(method_family = none)]
388 pub unsafe fn setName(&self, name: Option<&NSString>);
389
390 #[cfg(feature = "NSObjCRuntime")]
391 #[unsafe(method(qualityOfService))]
392 #[unsafe(method_family = none)]
393 pub unsafe fn qualityOfService(&self) -> NSQualityOfService;
394
395 #[cfg(feature = "NSObjCRuntime")]
396 #[unsafe(method(setQualityOfService:))]
398 #[unsafe(method_family = none)]
399 pub unsafe fn setQualityOfService(&self, quality_of_service: NSQualityOfService);
400
401 #[unsafe(method(cancelAllOperations))]
402 #[unsafe(method_family = none)]
403 pub unsafe fn cancelAllOperations(&self);
404
405 #[unsafe(method(waitUntilAllOperationsAreFinished))]
406 #[unsafe(method_family = none)]
407 pub unsafe fn waitUntilAllOperationsAreFinished(&self);
408
409 #[unsafe(method(currentQueue))]
410 #[unsafe(method_family = none)]
411 pub unsafe fn currentQueue() -> Option<Retained<NSOperationQueue>>;
412
413 #[unsafe(method(mainQueue))]
414 #[unsafe(method_family = none)]
415 pub unsafe fn mainQueue() -> Retained<NSOperationQueue>;
416 );
417}
418
419impl NSOperationQueue {
421 extern_methods!(
422 #[unsafe(method(init))]
423 #[unsafe(method_family = init)]
424 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
425
426 #[unsafe(method(new))]
427 #[unsafe(method_family = new)]
428 pub unsafe fn new() -> Retained<Self>;
429 );
430}
431
432impl NSOperationQueue {
434 extern_methods!(
435 #[cfg(feature = "NSArray")]
436 #[deprecated = "access to operations is inherently a race condition, it should not be used. For barrier style behaviors please use addBarrierBlock: instead"]
437 #[unsafe(method(operations))]
438 #[unsafe(method_family = none)]
439 pub unsafe fn operations(&self) -> Retained<NSArray<NSOperation>>;
440
441 #[deprecated]
442 #[unsafe(method(operationCount))]
443 #[unsafe(method_family = none)]
444 pub unsafe fn operationCount(&self) -> NSUInteger;
445 );
446}