class MultiThreadedConnector

Connects a source to one or more sinks, using a multi-threaded producer - consumer approach. More...

Definition#include <MultiThreadedConnector.h>
InheritsConnector [public virtual ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Protected Methods

Private Types

Private Methods

Private Members


Detailed Description

Connects a source to one or more sinks, using a multi-threaded producer - consumer approach.

ThreadData (class)

ThreadData

[private]

Helper class to collect information for starting threads.

pthread_mutex_t mutexProduce

mutexProduce

[private]

pthread_cond_t condProduce

condProduce

[private]

pthread_attr_t threadAttr

threadAttr

[private]

ThreadData * threads

threads

[private]

bool running

running

[private]

unsigned char * dataBuffer

dataBuffer

[private]

unsigned int dataSize

dataSize

[private]

void  init ( void )
throw ( Exception )

init

[private]

Initialize the object.

Throws: Exception

Reimplemented from Connector.

void  strip ( void )
throw ( Exception )

strip

[private]

De-initialize the object.

Throws: Exception

Reimplemented from Connector.

inline  MultiThreadedConnector ( void )
throw ( Exception )

MultiThreadedConnector

[protected]

Default constructor. Always throws an Exception.

Throws: Exception

inline  MultiThreadedConnector ( Source * source )
throw ( Exception )

MultiThreadedConnector

Constructor based on a Source.

Parameters:
sourcethe source to connect to the sinks.

Throws: Exception

inline  MultiThreadedConnector ( Source * source, Sink * sink )
throw ( Exception )

MultiThreadedConnector

Constructor based on a Source and a Sink.

Parameters:
sourcethe source to connect to the sinks.
sinka sink to connect to the source.

Throws: Exception

 MultiThreadedConnector ( const MultiThreadedConnector & connector )
throw ( Exception )

MultiThreadedConnector

Copy constructor.

Parameters:
connectorthe object to copy.

Throws: Exception

inline  ~MultiThreadedConnector ( void )
throw ( Exception )

~MultiThreadedConnector

[virtual]

Destructor.

Throws: Exception

MultiThreadedConnector &  operator= ( const MultiThreadedConnector & connector )
throw ( Exception )

operator=

[virtual]

Assignment operator.

Parameters:
connectorthe object to assign to this one.

Returns: a reference to this object.

Throws: Exception

Reimplemented from Connector.

bool  open ( void )
throw ( Exception )

open

[virtual]

Open the connector. Opens the Source and the Sinks if necessary.

Returns: true if opening was successful, false otherwise.

Throws: Exception

Reimplemented from Connector.

unsigned int  transfer ( unsigned long bytes, unsigned int bufSize, unsigned int sec, unsigned int usec )
throw ( Exception )

transfer

[virtual]

Transfer a given amount of data from the Source to all the Sinks attached. If an attached Sink closes or encounteres an error during the process, it is detached and the function carries on with the rest of the Sinks. If no Sinks remain, or an error is encountered with the Source, the function returns prematurely.

Parameters:
bytesthe amount of data to transfer, in bytes. If 0, transfer forever.
bufSizethe size of the buffer to use for transfering. This amount of data is read from the Source and written to each Sink on each turn.
secthe number of seconds to wait for the Source to have data available in each turn, and the number of seconds to wait for the Sinks to accept data.
usecthe number of micros seconds to wait for the Source to have data available in each turn, and the number of micro seconds to wait for the Sinks to accept data.

Returns: the number of bytes read from the Source.

Throws: Exception

Reimplemented from Connector.

void  close ( void )
throw ( Exception )

close

[virtual]

Close the Connector. The Source and all Sinks are closed.

Throws: Exception

Reimplemented from Connector.

void  sinkThread ( int ixSink )

sinkThread

This is the function for each thread. This function has to return fast

Parameters:
ixSinkthe index of the sink this thread works on.