mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
NSThread: Implement +detatchThreadWithBlock: and -initWithBlock: (#454)
* NSThread: Implement +detatchThreadWithBlock: and -initWithBlock: * Remove extraneous include * NSThread: Define GSThreadBlock so that GCC stub impl does not fail * Add missing spaces - trivial style fixup --------- Co-authored-by: rfm <richardfrithmacdonald@gmail.com>
This commit is contained in:
parent
cfc28d82bb
commit
fd5ec29bdf
2 changed files with 63 additions and 1 deletions
|
@ -43,6 +43,11 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_12, GS_API_LATEST)
|
||||
#import <GNUstepBase/GSBlocks.h>
|
||||
DEFINE_BLOCK_TYPE_NO_ARGS(GSThreadBlock, void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This class encapsulates OpenStep threading. See [NSLock] and its
|
||||
* subclasses for handling synchronisation between threads.<br />
|
||||
|
@ -67,6 +72,7 @@ GS_EXPORT_CLASS
|
|||
BOOL _cancelled;
|
||||
BOOL _active;
|
||||
BOOL _finished;
|
||||
BOOL _targetIsBlock;
|
||||
NSHandler *_exception_handler; // Not retained.
|
||||
NSMutableDictionary *_thread_dictionary;
|
||||
struct autorelease_thread_vars _autorelease_vars;
|
||||
|
@ -398,6 +404,29 @@ GS_EXPORT void GSUnregisterCurrentThread (void);
|
|||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This category contains convenience
|
||||
* initialisers and methods for executing
|
||||
* blocks in different threads and creating
|
||||
* NSThread objects with a block as entry point.
|
||||
*/
|
||||
@interface NSThread (BlockAdditions)
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_12, GS_API_LATEST)
|
||||
/**
|
||||
* Detaches a new thread with block as its entry point.
|
||||
*/
|
||||
+ (void) detachNewThreadWithBlock: (GSThreadBlock)block;
|
||||
|
||||
/**
|
||||
* Initialises a NSThread object with block as the
|
||||
* entry point.
|
||||
*/
|
||||
- (instancetype) initWithBlock: (GSThreadBlock)block;
|
||||
#endif // OS_API_VERSION
|
||||
|
||||
@end
|
||||
|
||||
/*
|
||||
* Notification Strings.
|
||||
* NSBecomingMultiThreaded and NSThreadExiting are defined for strict
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue