Thread management class in mulle-objc. Provides 1:1 mapping to native threads with thread-local storage and autorelease pool management.
NSObject
mulle_atomic_pointer_t   _osThread;           // Native thread handle
mulle_atomic_pointer_t   _runLoop;            // Associated run loop
mulle_atomic_pointer_t   _nameUTF8String;     // Thread name
mulle_atomic_pointer_t   _cancelled;          // Cancellation flag
NSInvocation            *_invocation;         // Target invocation
id                       _userInfo;           // Thread-local storage
MulleThreadFunction_t   *_function;           // C function to run
void                    *_functionArgument;    // Function argument
struct mulle__pointerarray _finalizers;       // Cleanup objects
void                    *_poolconfiguration;   // Autorelease pool config
struct mulle_map         _map;                // Thread dictionary
int                      _rval;               // Return value
char                     _isObjectFunctionArgument;
char                     _isDetached;
char                     _threadDidGainAccess;+mainThread
- Returns main thread object+currentThread
- Returns current thread object+detachNewThreadSelector:toTarget:withObject:
- Creates and starts new thread+mulleThreadWithTarget:selector:object:
- Creates thread with target/selector+mulleThreadWithFunction:argument:
- Creates thread with C function+mulleThreadWithObjectFunction:object:
- Creates thread with object function-mulleStart
- Starts the thread-mulleJoin
- Waits for thread completion-start
- Legacy interface (detaches thread)-cancel
- Marks thread for cancellation-isCancelled
- Checks cancellation status+mulleIsMainThread
- Checks if current thread is main thread+isMultiThreaded
- Checks if multiple threads are running-mulleReturnStatus
- Gets thread return value-mulleNameUTF8String
- Gets thread name-mulleSetNameUTF8String:
- Sets thread name-mulleSetRunLoop:
- Sets thread’s run loop-mulleRunLoop
- Gets thread’s run loop-mulleAddFinalizer:
- Adds cleanup object-mulleRemoveFinalizer:
- Removes cleanup object// Create and start thread with selector
[NSThread detachNewThreadSelector:@selector(doWork:)
                        toTarget:self
                      withObject:data];
// Create thread with C function
NSThread *thread = [NSThread mulleThreadWithFunction:workerFunction 
                                          argument:data];
[thread mulleStart];
[thread mulleJoin];
// Create thread with block
NSThread *thread = [NSThread mulleThreadWithObjectFunction:^(NSThread *thread, id obj) {
    // Thread work here
    return 0;
} object:data];
[thread mulleStart];