ObjFW
Public Member Functions | Static Public Member Functions
OFThread Class Reference

A class which provides portable threads. More...

#import <OFThread.h>

Inheritance diagram for OFThread:
OFObject <OFObject>

List of all members.

Public Member Functions

(id) - initWithObject:
 Initializes an already allocated thread with the specified object.
(id) - initWithBlock:
 Initializes an already allocated thread with the specified block.
(id) - initWithBlock:object:
 Initializes an already allocated thread with the specified block and object.
(id) - main
 The main routine of the thread. You need to reimplement this!
(void) - handleTermination
 This routine is exectued when the thread's main method has finished executing or terminate has been called.
(void) - start
 Starts the thread.
(id) - join
 Joins a thread.

Static Public Member Functions

(id) + thread
 Creates a new thread.
(id) + threadWithObject:
 Creates a new thread with the specified object.
(id) + threadWithBlock:
 Creates a new thread with the specified block.
(id) + threadWithBlock:object:
 Creates a new thread with the specified block and object.
(void) + setObject:forTLSKey:
 Sets the Thread Local Storage for the specified key.
(id) + objectForTLSKey:
 Returns the object for the specified Thread Local Storage key.
(OFThread *) + currentThread
 Returns the current thread.
(void) + sleepForTimeInterval:
 Suspends execution of the current thread for the specified time interval.
(void) + sleepUntilDate:
 Suspends execution of the current thread until the specified date.
(void) + yield
 Yields a processor voluntarily and moves the thread at the end of the queue for its priority.
(void) + terminate
 Terminates the current thread, letting it return nil.
(void) + terminateWithObject:
 Terminates the current thread, letting it return the specified object.

Detailed Description

A class which provides portable threads.

To use it, you should create a new class derived from it and reimplement main.


Member Function Documentation

+ (OFThread *) currentThread

Returns the current thread.

Returns:
The current thread or nil if we are in the main thread
- (id) initWithBlock: (of_thread_block_t)  block

Initializes an already allocated thread with the specified block.

Parameters:
blockA block which is executed by the thread
Returns:
An initialized OFThread.
- (id) initWithBlock: (of_thread_block_t)  block
object: (id)  object 

Initializes an already allocated thread with the specified block and object.

Parameters:
blockA block which is executed by the thread
objectAn object which is passed for use in the main method or nil
Returns:
An initialized OFThread.
- (id) initWithObject: (id)  object

Initializes an already allocated thread with the specified object.

Parameters:
objectAn object which is passed for use in the main method or nil
Returns:
An initialized OFThread.
- (id) join

Joins a thread.

Returns:
The object returned by the main method of the thread.
- (id) main

The main routine of the thread. You need to reimplement this!

It can access the object passed to the threadWithObject or initWithObject method using the instance variable named object.

Returns:
The object the join method should return when called for this thread
+ (id) objectForTLSKey: (OFTLSKey*)  key

Returns the object for the specified Thread Local Storage key.

The returned object is not retained and autoreleased for performance reasons!

Parameters:
keyThe Thread Local Storage key
+ (void) setObject: (id)  object
forTLSKey: (OFTLSKey*)  key 

Sets the Thread Local Storage for the specified key.

The specified object is first retained and then the object stored before is released. You can specify nil as object if you want the old object to be released and don't want any new object for the TLS key.

Parameters:
keyThe Thread Local Storage key
objectThe object the Thread Local Storage key will be set to
+ (void) sleepForTimeInterval: (double)  seconds

Suspends execution of the current thread for the specified time interval.

Parameters:
secondsThe number of seconds to sleep
+ (void) sleepUntilDate: (OFDate*)  date

Suspends execution of the current thread until the specified date.

Parameters:
dateThe date to wait for
+ (void) terminateWithObject: (id)  object

Terminates the current thread, letting it return the specified object.

Parameters:
objectThe object which the terminated thread will return
+ (id) thread

Creates a new thread.

Returns:
A new, autoreleased thread
+ (id) threadWithBlock: (of_thread_block_t)  block

Creates a new thread with the specified block.

Parameters:
blockA block which is executed by the thread
Returns:
A new, autoreleased thread
+ (id) threadWithBlock: (of_thread_block_t)  block
object: (id)  object 

Creates a new thread with the specified block and object.

Parameters:
blockA block which is executed by the thread
objectAn object which is passed for use in the main method or nil
Returns:
A new, autoreleased thread
+ (id) threadWithObject: (id)  object

Creates a new thread with the specified object.

Parameters:
objectAn object which is passed for use in the main method or nil
Returns:
A new, autoreleased thread

The documentation for this class was generated from the following files:
 All Classes Functions Variables Properties