csp::InfiniteFIFOBuffer< DATA_TYPE > Class Template Reference
[Channel Buffers]

Inheritance diagram for csp::InfiniteFIFOBuffer< DATA_TYPE >:

csp::ChannelBuffer< DATA_TYPE > boost::noncopyable List of all members.

Detailed Description

template<typename DATA_TYPE>
class csp::InfiniteFIFOBuffer< DATA_TYPE >

A FIFO buffer of unlimited capacity.

This is a FIFO (First-In First-Out) buffer that can grow to any size. Be very careful when using this buffer, as a channel can inadvertently use up as much memory as your system allows, especially if the receiver deadlocks or otherwise unexpectedly terminates. It is advised that you use a FIFOBuffer with a high capacity instead, but sometimes an infinite buffer can be useful.

DATA_TYPE Requirements

DATA_TYPE must have a copy constructor and support assignment.


Public Types

typedef ChannelBufferFactoryImpl<
DATA_TYPE, InfiniteFIFOBuffer<
DATA_TYPE > > 
Factory
 A channel buffer factory that can be used with this buffer.

Public Member Functions

virtual void beginExtGet (DATA_TYPE *dest)
 Starts an extended input from the buffer.
virtual void clear ()
 Clears all data from the buffer.
virtual void endExtGet ()
 Ends the current extended input from the buffer.
virtual void get (DATA_TYPE *dest)
 Gets a single item of data from the buffer.
virtual bool inputWouldSucceed ()
 Checks whether an input would succeed on the buffer.
virtual bool outputWouldSucceed (const DATA_TYPE *)
 Checks whether an output (of a specific item of data) would succeed on the buffer.
virtual void put (const DATA_TYPE *source)
 Adds a single item of data to the buffer.


Member Typedef Documentation

template<typename DATA_TYPE>
typedef ChannelBufferFactoryImpl<DATA_TYPE,InfiniteFIFOBuffer<DATA_TYPE> > csp::InfiniteFIFOBuffer< DATA_TYPE >::Factory

A channel buffer factory that can be used with this buffer.


Member Function Documentation

template<typename DATA_TYPE>
virtual bool csp::InfiniteFIFOBuffer< DATA_TYPE >::inputWouldSucceed (  )  [inline, virtual]

Checks whether an input would succeed on the buffer.

Informally, inputWouldSucceed() will return true when the buffer is non-empty, but false when the buffer is empty.

Sub-classes will implement this method.

This method must return false at some point (i.e. the buffer must be emptyable). Because poison from writer to reader is only noticed when this method returns false, this method must at some point return false to allow a writer's poison to transmit properly.

This restriction should not be a problem for most buffers (intuitively, buffers should be empty once all data has been read from them). The sort of buffer that you should avoid implementing is one where data is (for example) forever overwritten but never actually removed from the buffer (so that a reader can always read the most recent value, over and over again). To produce the same effect, use a process that holds the value, with request/reply channels for accessing the value.

Implements csp::ChannelBuffer< DATA_TYPE >.

template<typename DATA_TYPE>
virtual bool csp::InfiniteFIFOBuffer< DATA_TYPE >::outputWouldSucceed ( const DATA_TYPE *   )  [inline, virtual]

Checks whether an output (of a specific item of data) would succeed on the buffer.

Informally, outputWouldSucceed() will return true when the buffer is not full, but false when the buffer is full.

Passing the item of data allows buffers that may depend on the particular item given (particularly buffers that in some way aggregate the buffered data, or deal with items that can have different sizes).

Sub-classes will implement this method.

source must not be NULL.

Implements csp::ChannelBuffer< DATA_TYPE >.

template<typename DATA_TYPE>
virtual void csp::InfiniteFIFOBuffer< DATA_TYPE >::get ( DATA_TYPE *  dest  )  [inline, virtual]

Gets a single item of data from the buffer.

The item of data is copied into dest and then removed from the buffer

Sub-classes will implement this method.

Precondition:
this method will not be called when inputWouldSucceed() returns false
Parameters:
dest A pointer to the destination to copy the data into. dest must not be NULL.

Implements csp::ChannelBuffer< DATA_TYPE >.

template<typename DATA_TYPE>
virtual void csp::InfiniteFIFOBuffer< DATA_TYPE >::beginExtGet ( DATA_TYPE *  dest  )  [inline, virtual]

Starts an extended input from the buffer.

Sub-classes should implement this method.

The implementation of this method for a new buffer may not be obvious. Put simply, when a channel begins an extended input on a buffered channel, it calls this beginExtGet method on the buffer. When the channel finishes the extended input, it calls endExtGet on the buffer. Each beginExtGet call will be followed by an extEndGet before the next beginEndGet call. How you implement these methods will require thinking about how the semantics of an extended input on your buffer.

Examples of semantic implementations can be found in the buffers provided with C++CSP2. See the Channel Buffers page for more information.

Precondition:
this method will not be called when inputWouldSucceed() returns false
Parameters:
dest A pointer to the destination to copy the data into. dest must not be NULL.

Implements csp::ChannelBuffer< DATA_TYPE >.

template<typename DATA_TYPE>
virtual void csp::InfiniteFIFOBuffer< DATA_TYPE >::endExtGet (  )  [inline, virtual]

Ends the current extended input from the buffer.

Sub-classes should implement this method.

The implementation of this method for a new buffer may not be obvious. Put simply, when a channel begins an extended input on a buffered channel, it calls this beginExtGet method on the buffer. When the channel finishes the extended input, it calls endExtGet on the buffer. Each beginExtGet call will be followed by an extEndGet before the next beginEndGet call. How you implement these methods will require thinking about how the semantics of an extended input on your buffer.

endExtGet will always be called either:

In particular, the buffer may be empty when this method is called, so remember to check for that.

Examples of semantic implementations can be found in the buffers provided with C++CSP2. See the Channel Buffers page for more information.

Implements csp::ChannelBuffer< DATA_TYPE >.

template<typename DATA_TYPE>
virtual void csp::InfiniteFIFOBuffer< DATA_TYPE >::put ( const DATA_TYPE *  source  )  [inline, virtual]

Adds a single item of data to the buffer.

Sub-classes will implement this method.

Precondition:
this method will not be called when outputWouldSucceed(source) returns false
Parameters:
source A pointer to the source data to be added to the buffer. The data pointed to by source will be copied from, and the pointer does not have to remain valid after this call has returned. source must not be NULL.

Implements csp::ChannelBuffer< DATA_TYPE >.

template<typename DATA_TYPE>
virtual void csp::InfiniteFIFOBuffer< DATA_TYPE >::clear (  )  [inline, virtual]

Clears all data from the buffer.

Postcondition:
inputWouldSucceed() will return false

Implements csp::ChannelBuffer< DATA_TYPE >.


Generated on Mon Aug 20 12:24:29 2007 for C++CSP2 by  doxygen 1.4.7