STDThread
@interface STDThread : NSObject
Objective-C wrapper class for C++ std::thread
-
Designated initializer.
Note that initializing a
STDThread
object will launch a new thread immediately.Declaration
Objective-C
- (nonnull instancetype)initWithClosure:(nonnull void (^)(void))closure;
Parameters
closure
The closure/block to execute in the new thread. @returns The initialized instance.
-
Whether the thread is joinable.
Declaration
Objective-C
@property (readonly, nonatomic) BOOL joinable;
-
The number of concurrent threads supported by the implementation. The value should be considered only a hint.
Declaration
Objective-C
@property (readonly, nonatomic, class) unsigned int hardwareConcurrency;
-
Waits for a thread to finish its execution.
Declaration
Objective-C
- (BOOL)join:(NSError *_Nullable *_Nullable)error;
Parameters
error
An optional error object indicating any error upon return. @returns YES if the thread was successcvully joined, otherwise NO.
-
Permits the thread to execute independently from the thread handle.
Declaration
Objective-C
- (BOOL)detach:(NSError *_Nullable *_Nullable)error;
Parameters
error
An optional error object indicating any error upon return. @returns YES if the thread was successcvully detached, otherwise NO.