Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

MultiThreadedConnector Class Reference

#include <MultiThreadedConnector.h>

Inheritance diagram for MultiThreadedConnector:

Inheritance graph
[legend]
Collaboration diagram for MultiThreadedConnector:

Collaboration graph
[legend]
List of all members.

Detailed Description

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

Author:
Author
darkeye
Version:
Revision
1.5

Definition at line 74 of file MultiThreadedConnector.h.

Public Member Functions

 MultiThreadedConnector (Source *source, bool reconnect) throw ( Exception )
 Constructor based on a Source.
 MultiThreadedConnector (Source *source, Sink *sink, bool reconnect) throw ( Exception )
 Constructor based on a Source and a Sink.
 MultiThreadedConnector (const MultiThreadedConnector &connector) throw ( Exception )
 Copy constructor.
virtual ~MultiThreadedConnector (void) throw ( Exception )
 Destructor.
virtual MultiThreadedConnectoroperator= (const MultiThreadedConnector &connector) throw ( Exception )
 Assignment operator.
virtual bool open (void) throw ( Exception )
 Open the connector.
virtual unsigned int transfer (unsigned long bytes, unsigned int bufSize, unsigned int sec, unsigned int usec) throw ( Exception )
 Transfer a given amount of data from the Source to all the Sinks attached.
virtual void close (void) throw ( Exception )
 Close the Connector.
void sinkThread (int ixSink)
 This is the function for each thread.

Protected Member Functions

 MultiThreadedConnector (void) throw ( Exception )
 Default constructor.

Classes

class  ThreadData
 Helper class to collect information for starting threads.


Constructor & Destructor Documentation

MultiThreadedConnector::MultiThreadedConnector void   )  throw ( Exception ) [inline, protected]
 

Default constructor.

Always throws an Exception.

Exceptions:
Exception 

Definition at line 202 of file MultiThreadedConnector.h.

MultiThreadedConnector::MultiThreadedConnector Source source,
bool  reconnect
throw ( Exception ) [inline]
 

Constructor based on a Source.

Parameters:
source the source to connect to the sinks.
reconnect flag to indicate if the connector should try to reconnect if the connection was dropped by the other end
Exceptions:
Exception 

Definition at line 220 of file MultiThreadedConnector.h.

MultiThreadedConnector::MultiThreadedConnector Source source,
Sink sink,
bool  reconnect
throw ( Exception ) [inline]
 

Constructor based on a Source and a Sink.

Parameters:
source the source to connect to the sinks.
sink a sink to connect to the source.
reconnect flag to indicate if the connector should try to reconnect if the connection was dropped by the other end
Exceptions:
Exception 

Definition at line 239 of file MultiThreadedConnector.h.

MultiThreadedConnector::MultiThreadedConnector const MultiThreadedConnector connector  )  throw ( Exception )
 

Copy constructor.

Parameters:
connector the object to copy.
Exceptions:
Exception 

Definition at line 96 of file MultiThreadedConnector.cpp.

virtual MultiThreadedConnector::~MultiThreadedConnector void   )  throw ( Exception ) [inline, virtual]
 

Destructor.

Exceptions:
Exception 

Definition at line 263 of file MultiThreadedConnector.h.


Member Function Documentation

void MultiThreadedConnector::close void   )  throw ( Exception ) [virtual]
 

Close the Connector.

The Source and all Sinks are closed.

Exceptions:
Exception 

Reimplemented from Connector.

Definition at line 340 of file MultiThreadedConnector.cpp.

References Connector::close().

bool MultiThreadedConnector::open void   )  throw ( Exception ) [virtual]
 

Open the connector.

Opens the Source and the Sinks if necessary.

Returns:
true if opening was successful, false otherwise.
Exceptions:
Exception 

Reimplemented from Connector.

Definition at line 147 of file MultiThreadedConnector.cpp.

References Reporter::reportEvent().

MultiThreadedConnector & MultiThreadedConnector::operator= const MultiThreadedConnector connector  )  throw ( Exception ) [virtual]
 

Assignment operator.

Parameters:
connector the object to assign to this one.
Returns:
a reference to this object.
Exceptions:
Exception 

Definition at line 119 of file MultiThreadedConnector.cpp.

References Connector::operator=().

void MultiThreadedConnector::sinkThread int  ixSink  ) 
 

This is the function for each thread.

This function has to return fast

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

Definition at line 280 of file MultiThreadedConnector.cpp.

References Sink::canWrite(), Sink::close(), Ref< T >::get(), Sink::isOpen(), Sink::open(), Reporter::reportEvent(), and Sink::write().

unsigned int MultiThreadedConnector::transfer unsigned long  bytes,
unsigned int  bufSize,
unsigned int  sec,
unsigned int  usec
throw ( Exception ) [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:
bytes the amount of data to transfer, in bytes. If 0, transfer forever.
bufSize the 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.
sec the 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.
usec the 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.
Exceptions:
Exception 

Reimplemented from Connector.

Definition at line 212 of file MultiThreadedConnector.cpp.


The documentation for this class was generated from the following files:
Generated on Thu Apr 14 13:59:13 2005 for DarkIce by  doxygen 1.4.1