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.
BufferedOne2OneChannel::reader()
BufferedOne2AnyChannel::reader()
BufferedAny2OneChannel::reader()
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. |
csp::Chanout< DATA_TYPE >::Chanout | ( | const Chanout< DATA_TYPE > & | cho | ) | [inline] |
A standard copy constructor.
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();
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
source | The source of the output. Must not be NULL |
void csp::Chanout< DATA_TYPE >::write | ( | const DATA_TYPE * | source | ) | const [inline] |
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;
obj | The variable to output from |
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
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
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.