objc2_foundation/generated/
NSThread.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9extern_class!(
10    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsthread?language=objc)
11    #[unsafe(super(NSObject))]
12    #[derive(Debug, PartialEq, Eq, Hash)]
13    pub struct NSThread;
14);
15
16extern_conformance!(
17    unsafe impl NSObjectProtocol for NSThread {}
18);
19
20impl NSThread {
21    extern_methods!(
22        #[unsafe(method(currentThread))]
23        #[unsafe(method_family = none)]
24        pub fn currentThread() -> Retained<NSThread>;
25
26        #[cfg(feature = "block2")]
27        #[unsafe(method(detachNewThreadWithBlock:))]
28        #[unsafe(method_family = none)]
29        pub unsafe fn detachNewThreadWithBlock(block: &block2::DynBlock<dyn Fn()>);
30
31        #[unsafe(method(detachNewThreadSelector:toTarget:withObject:))]
32        #[unsafe(method_family = none)]
33        pub unsafe fn detachNewThreadSelector_toTarget_withObject(
34            selector: Sel,
35            target: &AnyObject,
36            argument: Option<&AnyObject>,
37        );
38
39        #[unsafe(method(isMultiThreaded))]
40        #[unsafe(method_family = none)]
41        pub fn isMultiThreaded() -> bool;
42
43        #[cfg(feature = "NSDictionary")]
44        #[unsafe(method(threadDictionary))]
45        #[unsafe(method_family = none)]
46        pub unsafe fn threadDictionary(&self) -> Retained<NSMutableDictionary>;
47
48        #[cfg(feature = "NSDate")]
49        #[unsafe(method(sleepUntilDate:))]
50        #[unsafe(method_family = none)]
51        pub unsafe fn sleepUntilDate(date: &NSDate);
52
53        #[cfg(feature = "NSDate")]
54        #[unsafe(method(sleepForTimeInterval:))]
55        #[unsafe(method_family = none)]
56        pub unsafe fn sleepForTimeInterval(ti: NSTimeInterval);
57
58        #[unsafe(method(exit))]
59        #[unsafe(method_family = none)]
60        pub unsafe fn exit();
61
62        #[unsafe(method(threadPriority))]
63        #[unsafe(method_family = none)]
64        pub unsafe fn threadPriority_class() -> c_double;
65
66        #[unsafe(method(setThreadPriority:))]
67        #[unsafe(method_family = none)]
68        pub unsafe fn setThreadPriority_class(p: c_double) -> bool;
69
70        #[unsafe(method(threadPriority))]
71        #[unsafe(method_family = none)]
72        pub unsafe fn threadPriority(&self) -> c_double;
73
74        /// Setter for [`threadPriority`][Self::threadPriority].
75        #[unsafe(method(setThreadPriority:))]
76        #[unsafe(method_family = none)]
77        pub unsafe fn setThreadPriority(&self, thread_priority: c_double);
78
79        #[cfg(feature = "NSObjCRuntime")]
80        #[unsafe(method(qualityOfService))]
81        #[unsafe(method_family = none)]
82        pub unsafe fn qualityOfService(&self) -> NSQualityOfService;
83
84        #[cfg(feature = "NSObjCRuntime")]
85        /// Setter for [`qualityOfService`][Self::qualityOfService].
86        #[unsafe(method(setQualityOfService:))]
87        #[unsafe(method_family = none)]
88        pub unsafe fn setQualityOfService(&self, quality_of_service: NSQualityOfService);
89
90        #[cfg(all(feature = "NSArray", feature = "NSValue"))]
91        #[unsafe(method(callStackReturnAddresses))]
92        #[unsafe(method_family = none)]
93        pub unsafe fn callStackReturnAddresses() -> Retained<NSArray<NSNumber>>;
94
95        #[cfg(all(feature = "NSArray", feature = "NSString"))]
96        #[unsafe(method(callStackSymbols))]
97        #[unsafe(method_family = none)]
98        pub unsafe fn callStackSymbols() -> Retained<NSArray<NSString>>;
99
100        #[cfg(feature = "NSString")]
101        #[unsafe(method(name))]
102        #[unsafe(method_family = none)]
103        pub fn name(&self) -> Option<Retained<NSString>>;
104
105        #[cfg(feature = "NSString")]
106        /// Setter for [`name`][Self::name].
107        #[unsafe(method(setName:))]
108        #[unsafe(method_family = none)]
109        pub unsafe fn setName(&self, name: Option<&NSString>);
110
111        #[unsafe(method(stackSize))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn stackSize(&self) -> NSUInteger;
114
115        /// Setter for [`stackSize`][Self::stackSize].
116        #[unsafe(method(setStackSize:))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn setStackSize(&self, stack_size: NSUInteger);
119
120        #[unsafe(method(isMainThread))]
121        #[unsafe(method_family = none)]
122        pub fn isMainThread(&self) -> bool;
123
124        #[unsafe(method(isMainThread))]
125        #[unsafe(method_family = none)]
126        pub fn isMainThread_class() -> bool;
127
128        #[unsafe(method(mainThread))]
129        #[unsafe(method_family = none)]
130        pub fn mainThread() -> Retained<NSThread>;
131
132        #[unsafe(method(init))]
133        #[unsafe(method_family = init)]
134        pub fn init(this: Allocated<Self>) -> Retained<Self>;
135
136        #[unsafe(method(initWithTarget:selector:object:))]
137        #[unsafe(method_family = init)]
138        pub unsafe fn initWithTarget_selector_object(
139            this: Allocated<Self>,
140            target: &AnyObject,
141            selector: Sel,
142            argument: Option<&AnyObject>,
143        ) -> Retained<Self>;
144
145        #[cfg(feature = "block2")]
146        #[unsafe(method(initWithBlock:))]
147        #[unsafe(method_family = init)]
148        pub unsafe fn initWithBlock(
149            this: Allocated<Self>,
150            block: &block2::DynBlock<dyn Fn()>,
151        ) -> Retained<Self>;
152
153        #[unsafe(method(isExecuting))]
154        #[unsafe(method_family = none)]
155        pub unsafe fn isExecuting(&self) -> bool;
156
157        #[unsafe(method(isFinished))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn isFinished(&self) -> bool;
160
161        #[unsafe(method(isCancelled))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn isCancelled(&self) -> bool;
164
165        #[unsafe(method(cancel))]
166        #[unsafe(method_family = none)]
167        pub unsafe fn cancel(&self);
168
169        #[unsafe(method(start))]
170        #[unsafe(method_family = none)]
171        pub unsafe fn start(&self);
172
173        #[unsafe(method(main))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn main(&self);
176    );
177}
178
179/// Methods declared on superclass `NSObject`.
180impl NSThread {
181    extern_methods!(
182        #[unsafe(method(new))]
183        #[unsafe(method_family = new)]
184        pub fn new() -> Retained<Self>;
185    );
186}
187
188impl DefaultRetained for NSThread {
189    #[inline]
190    fn default_retained() -> Retained<Self> {
191        Self::new()
192    }
193}
194
195extern "C" {
196    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nswillbecomemultithreadednotification?language=objc)
197    #[cfg(all(feature = "NSNotification", feature = "NSString"))]
198    pub static NSWillBecomeMultiThreadedNotification: &'static NSNotificationName;
199}
200
201extern "C" {
202    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsdidbecomesinglethreadednotification?language=objc)
203    #[cfg(all(feature = "NSNotification", feature = "NSString"))]
204    pub static NSDidBecomeSingleThreadedNotification: &'static NSNotificationName;
205}
206
207extern "C" {
208    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsthreadwillexitnotification?language=objc)
209    #[cfg(all(feature = "NSNotification", feature = "NSString"))]
210    pub static NSThreadWillExitNotification: &'static NSNotificationName;
211}
212
213mod private_NSObjectNSThreadPerformAdditions {
214    pub trait Sealed {}
215}
216
217/// Category "NSThreadPerformAdditions" on [`NSObject`].
218#[doc(alias = "NSThreadPerformAdditions")]
219pub unsafe trait NSObjectNSThreadPerformAdditions:
220    ClassType + Sized + private_NSObjectNSThreadPerformAdditions::Sealed
221{
222    extern_methods!(
223        #[cfg(all(feature = "NSArray", feature = "NSString"))]
224        #[unsafe(method(performSelectorOnMainThread:withObject:waitUntilDone:modes:))]
225        #[unsafe(method_family = none)]
226        unsafe fn performSelectorOnMainThread_withObject_waitUntilDone_modes(
227            &self,
228            a_selector: Sel,
229            arg: Option<&AnyObject>,
230            wait: bool,
231            array: Option<&NSArray<NSString>>,
232        );
233
234        #[unsafe(method(performSelectorOnMainThread:withObject:waitUntilDone:))]
235        #[unsafe(method_family = none)]
236        unsafe fn performSelectorOnMainThread_withObject_waitUntilDone(
237            &self,
238            a_selector: Sel,
239            arg: Option<&AnyObject>,
240            wait: bool,
241        );
242
243        #[cfg(all(feature = "NSArray", feature = "NSString"))]
244        #[unsafe(method(performSelector:onThread:withObject:waitUntilDone:modes:))]
245        #[unsafe(method_family = none)]
246        unsafe fn performSelector_onThread_withObject_waitUntilDone_modes(
247            &self,
248            a_selector: Sel,
249            thr: &NSThread,
250            arg: Option<&AnyObject>,
251            wait: bool,
252            array: Option<&NSArray<NSString>>,
253        );
254
255        #[unsafe(method(performSelector:onThread:withObject:waitUntilDone:))]
256        #[unsafe(method_family = none)]
257        unsafe fn performSelector_onThread_withObject_waitUntilDone(
258            &self,
259            a_selector: Sel,
260            thr: &NSThread,
261            arg: Option<&AnyObject>,
262            wait: bool,
263        );
264
265        #[unsafe(method(performSelectorInBackground:withObject:))]
266        #[unsafe(method_family = none)]
267        unsafe fn performSelectorInBackground_withObject(
268            &self,
269            a_selector: Sel,
270            arg: Option<&AnyObject>,
271        );
272    );
273}
274
275impl private_NSObjectNSThreadPerformAdditions::Sealed for NSObject {}
276unsafe impl NSObjectNSThreadPerformAdditions for NSObject {}