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
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:))]
31 #[unsafe(method_family = none)]
32 pub unsafe fn detachNewThreadWithBlock(block: &block2::DynBlock<dyn Fn()>);
33
34 #[unsafe(method(detachNewThreadSelector:toTarget:withObject:))]
40 #[unsafe(method_family = none)]
41 pub unsafe fn detachNewThreadSelector_toTarget_withObject(
42 selector: Sel,
43 target: &AnyObject,
44 argument: Option<&AnyObject>,
45 );
46
47 #[unsafe(method(isMultiThreaded))]
48 #[unsafe(method_family = none)]
49 pub fn isMultiThreaded() -> bool;
50
51 #[cfg(feature = "NSDictionary")]
52 #[unsafe(method(threadDictionary))]
56 #[unsafe(method_family = none)]
57 pub unsafe fn threadDictionary(&self) -> Retained<NSMutableDictionary>;
58
59 #[cfg(feature = "NSDate")]
60 #[unsafe(method(sleepUntilDate:))]
61 #[unsafe(method_family = none)]
62 pub fn sleepUntilDate(date: &NSDate);
63
64 #[cfg(feature = "NSDate")]
65 #[unsafe(method(sleepForTimeInterval:))]
66 #[unsafe(method_family = none)]
67 pub fn sleepForTimeInterval(ti: NSTimeInterval);
68
69 #[unsafe(method(exit))]
70 #[unsafe(method_family = none)]
71 pub fn exit();
72
73 #[unsafe(method(threadPriority))]
74 #[unsafe(method_family = none)]
75 pub fn threadPriority_class() -> c_double;
76
77 #[unsafe(method(setThreadPriority:))]
78 #[unsafe(method_family = none)]
79 pub fn setThreadPriority_class(p: c_double) -> bool;
80
81 #[unsafe(method(threadPriority))]
82 #[unsafe(method_family = none)]
83 pub fn threadPriority(&self) -> c_double;
84
85 #[unsafe(method(setThreadPriority:))]
87 #[unsafe(method_family = none)]
88 pub fn setThreadPriority(&self, thread_priority: c_double);
89
90 #[cfg(feature = "NSObjCRuntime")]
91 #[unsafe(method(qualityOfService))]
92 #[unsafe(method_family = none)]
93 pub fn qualityOfService(&self) -> NSQualityOfService;
94
95 #[cfg(feature = "NSObjCRuntime")]
96 #[unsafe(method(setQualityOfService:))]
98 #[unsafe(method_family = none)]
99 pub fn setQualityOfService(&self, quality_of_service: NSQualityOfService);
100
101 #[cfg(all(feature = "NSArray", feature = "NSValue"))]
102 #[unsafe(method(callStackReturnAddresses))]
103 #[unsafe(method_family = none)]
104 pub fn callStackReturnAddresses() -> Retained<NSArray<NSNumber>>;
105
106 #[cfg(all(feature = "NSArray", feature = "NSString"))]
107 #[unsafe(method(callStackSymbols))]
108 #[unsafe(method_family = none)]
109 pub fn callStackSymbols() -> Retained<NSArray<NSString>>;
110
111 #[cfg(feature = "NSString")]
112 #[unsafe(method(name))]
113 #[unsafe(method_family = none)]
114 pub fn name(&self) -> Option<Retained<NSString>>;
115
116 #[cfg(feature = "NSString")]
117 #[unsafe(method(setName:))]
121 #[unsafe(method_family = none)]
122 pub fn setName(&self, name: Option<&NSString>);
123
124 #[unsafe(method(stackSize))]
125 #[unsafe(method_family = none)]
126 pub fn stackSize(&self) -> NSUInteger;
127
128 #[unsafe(method(setStackSize:))]
130 #[unsafe(method_family = none)]
131 pub fn setStackSize(&self, stack_size: NSUInteger);
132
133 #[unsafe(method(isMainThread))]
134 #[unsafe(method_family = none)]
135 pub fn isMainThread(&self) -> bool;
136
137 #[unsafe(method(isMainThread))]
138 #[unsafe(method_family = none)]
139 pub fn isMainThread_class() -> bool;
140
141 #[unsafe(method(mainThread))]
142 #[unsafe(method_family = none)]
143 pub fn mainThread() -> Retained<NSThread>;
144
145 #[unsafe(method(init))]
146 #[unsafe(method_family = init)]
147 pub fn init(this: Allocated<Self>) -> Retained<Self>;
148
149 #[unsafe(method(initWithTarget:selector:object:))]
155 #[unsafe(method_family = init)]
156 pub unsafe fn initWithTarget_selector_object(
157 this: Allocated<Self>,
158 target: &AnyObject,
159 selector: Sel,
160 argument: Option<&AnyObject>,
161 ) -> Retained<Self>;
162
163 #[cfg(feature = "block2")]
164 #[unsafe(method(initWithBlock:))]
168 #[unsafe(method_family = init)]
169 pub unsafe fn initWithBlock(
170 this: Allocated<Self>,
171 block: &block2::DynBlock<dyn Fn()>,
172 ) -> Retained<Self>;
173
174 #[unsafe(method(isExecuting))]
175 #[unsafe(method_family = none)]
176 pub fn isExecuting(&self) -> bool;
177
178 #[unsafe(method(isFinished))]
179 #[unsafe(method_family = none)]
180 pub fn isFinished(&self) -> bool;
181
182 #[unsafe(method(isCancelled))]
183 #[unsafe(method_family = none)]
184 pub fn isCancelled(&self) -> bool;
185
186 #[unsafe(method(cancel))]
187 #[unsafe(method_family = none)]
188 pub fn cancel(&self);
189
190 #[unsafe(method(start))]
191 #[unsafe(method_family = none)]
192 pub fn start(&self);
193
194 #[unsafe(method(main))]
195 #[unsafe(method_family = none)]
196 pub unsafe fn main(&self);
197 );
198}
199
200impl NSThread {
202 extern_methods!(
203 #[unsafe(method(new))]
204 #[unsafe(method_family = new)]
205 pub fn new() -> Retained<Self>;
206 );
207}
208
209impl DefaultRetained for NSThread {
210 #[inline]
211 fn default_retained() -> Retained<Self> {
212 Self::new()
213 }
214}
215
216extern "C" {
217 #[cfg(all(feature = "NSNotification", feature = "NSString"))]
219 #[deprecated = "This notification does not protect against data races"]
220 pub static NSWillBecomeMultiThreadedNotification: &'static NSNotificationName;
221}
222
223extern "C" {
224 #[cfg(all(feature = "NSNotification", feature = "NSString"))]
226 #[deprecated = "Programs no longer transition to single-threaded mode from threaded environments"]
227 pub static NSDidBecomeSingleThreadedNotification: &'static NSNotificationName;
228}
229
230extern "C" {
231 #[cfg(all(feature = "NSNotification", feature = "NSString"))]
233 #[deprecated = "This notification does not protect against data races"]
234 pub static NSThreadWillExitNotification: &'static NSNotificationName;
235}
236
237mod private_NSObjectNSThreadPerformAdditions {
238 pub trait Sealed {}
239}
240
241#[doc(alias = "NSThreadPerformAdditions")]
243pub unsafe trait NSObjectNSThreadPerformAdditions:
244 ClassType + Sized + private_NSObjectNSThreadPerformAdditions::Sealed
245{
246 extern_methods!(
247 #[cfg(all(feature = "NSArray", feature = "NSString"))]
248 #[unsafe(method(performSelectorOnMainThread:withObject:waitUntilDone:modes:))]
253 #[unsafe(method_family = none)]
254 unsafe fn performSelectorOnMainThread_withObject_waitUntilDone_modes(
255 &self,
256 a_selector: Sel,
257 arg: Option<&AnyObject>,
258 wait: bool,
259 array: Option<&NSArray<NSString>>,
260 );
261
262 #[unsafe(method(performSelectorOnMainThread:withObject:waitUntilDone:))]
267 #[unsafe(method_family = none)]
268 unsafe fn performSelectorOnMainThread_withObject_waitUntilDone(
269 &self,
270 a_selector: Sel,
271 arg: Option<&AnyObject>,
272 wait: bool,
273 );
274
275 #[cfg(all(feature = "NSArray", feature = "NSString"))]
276 #[unsafe(method(performSelector:onThread:withObject:waitUntilDone:modes:))]
281 #[unsafe(method_family = none)]
282 unsafe fn performSelector_onThread_withObject_waitUntilDone_modes(
283 &self,
284 a_selector: Sel,
285 thr: &NSThread,
286 arg: Option<&AnyObject>,
287 wait: bool,
288 array: Option<&NSArray<NSString>>,
289 );
290
291 #[unsafe(method(performSelector:onThread:withObject:waitUntilDone:))]
296 #[unsafe(method_family = none)]
297 unsafe fn performSelector_onThread_withObject_waitUntilDone(
298 &self,
299 a_selector: Sel,
300 thr: &NSThread,
301 arg: Option<&AnyObject>,
302 wait: bool,
303 );
304
305 #[unsafe(method(performSelectorInBackground:withObject:))]
310 #[unsafe(method_family = none)]
311 unsafe fn performSelectorInBackground_withObject(
312 &self,
313 a_selector: Sel,
314 arg: Option<&AnyObject>,
315 );
316 );
317}
318
319impl private_NSObjectNSThreadPerformAdditions::Sealed for NSObject {}
320unsafe impl NSObjectNSThreadPerformAdditions for NSObject {}