MyThreadConnection Class Reference

This class implements a connection between threads in the same adress space. More...

#import <MyThreadConnection.h>

Inheritance diagram for MyThreadConnection:

Inheritance graph
[legend]
Collaboration diagram for MyThreadConnection:

Collaboration graph
[legend]

List of all members.

Public Member Functions

(NSPort *) - mainPort
 Accessor to the port of the "main" end of the connection.
(NSPort *) - threadPort
 Accessor to the port of the "thread" end of the connection.
(BOOL) - connectionIdle
 Check wether some message remains to be processed.
(NSProxy *) - proxyForObject:inThread:
 Creation of a proxy for the object controlling one thread.
(void) - setRootObject:
 Set the object controlling the creating thread.
(NSProxy *) - rootProxy
 Access to the proxy for the object controlling the creating thread.
(id) - initWithMainPort:threadPort:
 Connection initialization.
(id) - initWithMainPort:threadPort:queueSize:
 Connection initialization.

Static Public Member Functions

(void) + performSelectorOnMainThread:forObject:withArg:
 Call a selector on an object on the main thread.


Detailed Description

This class implements a connection between threads in the same adress space.

Contrary to the standard NSConnection, the arguments to inter-thread calls are passed by address. This saves time but forbid use in inter-process or network messaging.
The thread which creates the connection is called "main" hereunder, even though it can be any thread.


Member Function Documentation

- (NSPort *) mainPort  

Accessor to the port of the "main" end of the connection.

Returns:
The port

- (NSPort *) threadPort  

Accessor to the port of the "thread" end of the connection.

Returns:
The port

- (BOOL) connectionIdle  

Check wether some message remains to be processed.

Returns:
YES if no message is waiting to be processed You do not need to call this before releasing the connection as it itself waits for idle state before deallocating.

- (NSProxy *) proxyForObject: (id)  object
inThread: (BOOL)  inThread 

Creation of a proxy for the object controlling one thread.

Parameters:
object The controlling object
inThread Selects the created thread if YES
Returns:
The proxy for the object controlling the requested thread The proxy object shall not be retained by the "opposite" thread but released when appropriate.

- (void) setRootObject: (id)  anObject  

Set the object controlling the creating thread.

Parameters:
anObject The controlling object

- (NSProxy *) rootProxy  

Access to the proxy for the object controlling the creating thread.

Returns:
The proxy for the object controlling the creating thread This method shall be called at least once from the created thread as the first call registers the connection in the thread run loop.

+ (void) performSelectorOnMainThread: (SEL)  sel
forObject: (NSObject*)  target
withArg: (id)  arg 

Call a selector on an object on the main thread.

Parameters:
selector The selector to perform
target The target object
arg The only argument of the method being called The selector shall take only one argument of type id, or no argument at all.
The MyThreadConnection registered for the current thread will be used for sending the request.

- (id) initWithMainPort: (NSPort*)  mainPort
threadPort: (NSPort*)  threadPort 

Connection initialization.

Parameters:
mainPort The port of the creating thread
threadPort The port for the created thread
Returns:
The new connection

- (id) initWithMainPort: (NSPort*)  mainPort
threadPort: (NSPort*)  threadPort
queueSize: (int)  queueSize 

Connection initialization.

Parameters:
mainPort The port of the creating thread
threadPort The port for the created thread
queueSize Number of elements to queue when Mach port is full
Returns:
The new connection


The documentation for this class was generated from the following files:
Generated on Sat Mar 22 17:44:54 2008 for Lynkeos by  doxygen 1.5.4