Lynkeos
Instance Methods | Class Methods | List of all members
LynkeosThreadConnection Class Reference

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

#import <LynkeosThreadConnection.h>

Inheritance diagram for LynkeosThreadConnection:
Inheritance graph
[legend]
Collaboration diagram for LynkeosThreadConnection:
Collaboration graph
[legend]

Instance Methods

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

Class Methods

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

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.

Method Documentation

- (BOOL) connectionIdle

Check wether some message remains to be processed.

You do not need to call this before releasing the connection as it itself waits for idle state before deallocating.

Returns
YES if no message is waiting to be processed
- (id) initWithMainPort: (NSPort*)  mainPort
threadPort: (NSPort*)  threadPort 

Connection initialization.

Parameters
mainPortThe port of the creating thread
threadPortThe port for the created thread
Returns
The new connection
- (id) initWithMainPort: (NSPort*)  mainPort
threadPort: (NSPort*)  threadPort
queueSize: (int)  queueSize 

Connection initialization.

Parameters
mainPortThe port of the creating thread
threadPortThe port for the created thread
queueSizeNumber of elements to queue when Mach port is full
Returns
The new connection
- (NSPort *) mainPort

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

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

Call a selector on an object on the main thread.

The selector shall take only one argument of type id, or no argument at all.
The LynkeosThreadConnection registered for the current thread will be used for sending the request.

Parameters
selThe selector to perform
targetThe target object
argThe only argument of the method being called

Referenced by LynkeosProcessingParameterMgr::notifyItemModification:.

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

Creation of a proxy for the object controlling one thread.

The proxy shall be released (in either thread) before its connection is deallocated.

Parameters
objectThe controlling object
inThreadSelects the created thread if YES
Returns
The proxy for the object controlling the requested thread

Referenced by rootProxy.

- (NSProxy *) rootProxy

Access to 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.

Returns
The proxy for the object controlling the creating thread

References proxyForObject:inThread:.

- (void) setRootObject: (id)  anObject

Set the object controlling the creating thread.

Parameters
anObjectThe controlling object
- (NSPort *) threadPort

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

Returns
The port

Referenced by MyProcessingThread::threadWithAttributes:.


The documentation for this class was generated from the following files: