csp::Chanout< DATA_TYPE > Class Template Reference
[Channel Ends]

List of all members.

Detailed Description

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

The writing end of a channel.

This class is returned by functions like One2OneChannel::writer() to return a writing end of a channel (that carries items of type DATA_TYPE). More information can be found on the Channel Ends page and in the Channels section of the guide.

They are small classes (the size of a pointer and a boolean) that can be assigned around but only one writing end on a channel should be in use at any one time for the one-to-one and one-to-any channel types.

The mobile channel-ends paradigm may be implemented by simply encasing the channel end in a mobile, i.e. Mobile< Chanout<int> > for ints

This item can be used for normal outputting in one of two ways, either by using the output()/write() methods or by using the << operator so for example:

            One2OneChannel<int> chan;
            Chanout<int> out = chan.writer();
            int a,b;

            //This:
            out.output(&a);out.write(&b);

            //Is the same as this:
            out << a << b;

Note that the output/write functions take a pointer (rather than references) to make the fact that the location is assigned from, whereas for simplicity the << operator uses references, as out << a is more natural than out << &a.

This class can also be declared const easily as all its methods are const.

You should also read about the PoisonException that could be thrown, to understand poisoning channels.

C++CSP v1.x Compatibility

See the note in the Channel Ends module

See also:
One2OneChannel::reader()

One2AnyChannel::reader()

Any2OneChannel::reader()

Any2AnyChannel::reader()

BufferedOne2OneChannel::reader()

BufferedOne2AnyChannel::reader()

BufferedAny2OneChannel::reader()

BufferedAny2AnyChannel::reader()

AltChanin

Chanin

PoisonException


Public Member Functions

 Chanout ()
 A constructor for instances that are class members.
 Chanout (const Chanout< DATA_TYPE > &cho)
 A standard copy constructor.
void checkPoison () const
 Checks the channel for poison.
const Chanout< DATA_TYPE > & operator<< (const DATA_TYPE &obj) const
 Performs a normal output.
bool operator== (const csp::Chanout< DATA_TYPE > &b) const
 To allow sets of channel ends that are able to keep only one end per channel we define relational operators Note that a non-poisonable channel end is not equal to a poisonable channel end of the same channel.
void output (const DATA_TYPE *source) const
 Performs a normal output.
void poison () const
 Poisons the channel.
void write (const DATA_TYPE *source) const
 Identical to the output method.


Constructor & Destructor Documentation

template<typename DATA_TYPE>
csp::Chanout< DATA_TYPE >::Chanout ( const Chanout< DATA_TYPE > &  cho  )  [inline]

A standard copy constructor.

template<typename DATA_TYPE>
csp::Chanout< DATA_TYPE >::Chanout (  )  [inline]

A constructor for instances that are class members.

Do not use this constructor normally for constructing channel ends, instead use something like this:

                Chanout<int> chanout = somechannel.writer();
This constructor is provided because, as can be seen in the Delta common process, sometimes channel ends need to be class members but they cannot be initialised until the body of the constructor (rather than the initialiser list) so this default constructor is provided for that mode of use.


Member Function Documentation

template<typename DATA_TYPE>
void csp::Chanout< DATA_TYPE >::output ( const DATA_TYPE *  source  )  const [inline]

Performs a normal output.

This simply performs a normal output on the channel, from source It will not return until the output has completed

Parameters:
source The source of the output. Must not be NULL

template<typename DATA_TYPE>
void csp::Chanout< DATA_TYPE >::write ( const DATA_TYPE *  source  )  const [inline]

Identical to the output method.

See also:
output()

template<typename DATA_TYPE>
const Chanout<DATA_TYPE>& csp::Chanout< DATA_TYPE >::operator<< ( const DATA_TYPE &  obj  )  const [inline]

Performs a normal output.

Does the same as the output() function but takes a reference not a pointer. It can be used to easily chain sequential outputs as follows:

                One2OneChannel<int> chan;
                Chanout<int> out = chan.writer();
                int a,b;

                //This:
                in.output(&a);in.output(&b);

                //Is the same as this:
                in << a << b;

Parameters:
obj The variable to output from
Returns:
This channel, for chaining outputs

template<typename DATA_TYPE>
void csp::Chanout< DATA_TYPE >::poison (  )  const [inline]

Poisons the channel.

This poisons the channel, and can be safely called multiple times

Read about PoisonException for more information regarding poison

See also:
PoisonException

checkPoison()

template<typename DATA_TYPE>
void csp::Chanout< DATA_TYPE >::checkPoison (  )  const [inline]

Checks the channel for poison.

Rather than being an accessor for the poison flag, this function instead checks it and then returns normally if the channel is not poisoned, or throws a PoisonException if it is.

This function allows processes performing lots of calculations and no channel communications to check for poison more often than only checking when a channel communication is performed

See also:
PoisonException

poison()

template<typename DATA_TYPE>
bool csp::Chanout< DATA_TYPE >::operator== ( const csp::Chanout< DATA_TYPE > &  b  )  const [inline]

To allow sets of channel ends that are able to keep only one end per channel we define relational operators Note that a non-poisonable channel end is not equal to a poisonable channel end of the same channel.


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