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