1 /* Copyright (c) 2006-2007 Christopher J. W. Lloyd
3 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
9 #import <Foundation/NSException.h>
10 #import <Foundation/NSDate.h>
12 @
class NSDictionary
, NSMutableDictionary
, NSAutoreleasePool
, NSLock
;
14 FOUNDATION_EXPORT NSString
*const NSDidBecomeSingleThreadedNotification
;
15 FOUNDATION_EXPORT NSString
*const NSWillBecomeMultiThreadedNotification
;
16 FOUNDATION_EXPORT NSString
*const NSThreadWillExitNotification
;
18 @interface NSThread
: NSObject
{
19 NSMutableDictionary
*_dictionary
;
20 NSMutableDictionary
*_sharedObjects
;
21 NSLock
*_sharedObjectLock
;
22 NSAutoreleasePool
*_currentPool
;
23 NSExceptionFrame
*_currentHandler
;
33 + (BOOL
)isMultiThreaded
;
36 + (NSThread
*)mainThread
;
38 + (void)detachNewThreadSelector
:(SEL
)selector toTarget
:target
41 + (NSThread
*)currentThread
;
42 + (NSArray
*)callStackReturnAddresses
;
43 + (NSArray
*)callStackSymbols
;
45 + (double)threadPriority
;
46 + (BOOL
)setThreadPriority
:(double)value
;
48 + (void)sleepUntilDate
:(NSDate
*)date
;
49 + (void)sleepForTimeInterval
:(NSTimeInterval
)value
;
54 - initWithTarget
:target selector
:(SEL
)selector object
:argument
;
66 - (NSUInteger
)stackSize
;
68 - (NSMutableDictionary
*)threadDictionary
;
70 - (void)setName
:(NSString
*)value
;
71 - (void)setStackSize
:(NSUInteger
)value
;
74 - (NSMutableDictionary
*)sharedDictionary
;
75 - (void)setSharedObject
:object forClassName
:(NSString
*)className
;
79 @interface
NSObject (NSThread
)
80 - (void)performSelector
:(SEL
)selector onThread
:(NSThread
*)thread withObject
:(id
)object waitUntilDone
:(BOOL
)waitUntilDone modes
:(NSArray
*)modes
;
81 - (void)performSelector
:(SEL
)selector onThread
:(NSThread
*)thread withObject
:(id
)object waitUntilDone
:(BOOL
)waitUntilDone
;
82 - (void)performSelectorOnMainThread
:(SEL
)selector withObject
:object waitUntilDone
:(BOOL
)waitUntilDone modes
:(NSArray
*)modes
;
83 - (void)performSelectorOnMainThread
:(SEL
)selector withObject
:object waitUntilDone
:(BOOL
)waitUntilDone
;
84 - (void)performSelectorInBackground
:(SEL
)selector withObject
:object
;
88 FOUNDATION_EXPORT NSThread
*NSCurrentThread(void);
89 FOUNDATION_EXPORT id
NSThreadSharedInstance(NSString
*className
);
90 FOUNDATION_EXPORT id
NSThreadSharedInstanceDoNotCreate(NSString
*className
);