See the page on Channel Ends and the section on Channels in the guide.
C++CSP v1.x Compatibility:
See the note in the Channel Ends module
BufferedOne2OneChannel::reader()
Public Types | |
typedef ScopedExtInput< DATA_TYPE > | ScopedExtInput |
A typedef for the ScopedExtInput. | |
Public Member Functions | |
AltChanin () | |
A constructor for instances that are class members. | |
AltChanin (const AltChanin< DATA_TYPE > &cho) | |
A standard copy constructor. | |
void | checkPoison () const |
Checks the channel for poison. | |
void | extInput (DATA_TYPE *const dest, void(*function)()) const |
DEPRECATED; Performs an extended input. | |
template<class PROCESS> | |
void | extInput (DATA_TYPE *const dest, PROCESS *proc, void(PROCESS::*memberFn)()) const |
DEPRECATED; A syntax for performing an extended input. | |
void | input (DATA_TYPE *const dest) const |
Performs a normal input. | |
Guard * | inputGuard () const |
Gets an input guard to use in an ALT . | |
operator Chanin () const | |
Returns a copy with the Alt capability hidden. | |
bool | operator== (const csp::AltChanin< 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. | |
const AltChanin< DATA_TYPE > & | operator>> (DATA_TYPE &obj) const |
Performs a normal input. | |
bool | pending () const |
Checks whether an input would finish immediately on the channel. | |
void | poison () const |
Poisons the channel. | |
void | read (DATA_TYPE *const dest) const |
Identical to the input method. |
typedef ScopedExtInput<DATA_TYPE> csp::AltChanin< DATA_TYPE >::ScopedExtInput |
A typedef for the ScopedExtInput.
Chanin<DATA_TYPE>::ScopedExtInput is equivalent to ScopedExtInput<DATA_TYPE>
csp::AltChanin< DATA_TYPE >::AltChanin | ( | const AltChanin< DATA_TYPE > & | cho | ) | [inline] |
A standard copy constructor.
csp::AltChanin< DATA_TYPE >::AltChanin | ( | ) | [inline] |
A constructor for instances that are class members.
Do not use this constructor for constructing channel ends, instead use something like this:
Chanin<int> chanin = somechannel.reader();
csp::AltChanin< DATA_TYPE >::operator Chanin | ( | ) | const [inline] |
Returns a copy with the Alt capability hidden.
This is useful for passing the channel end to processes that do not need the ALTing capability
Guard* csp::AltChanin< DATA_TYPE >::inputGuard | ( | ) | const [inline] |
Gets an input guard to use in an ALT
.
The guard will be ready when either there is data to be read, or the channel is poisoned. If an input guard for a channel is selected by the Alternative, you must then perform an input or extended input on the channel as your next action.
The Alternative class will delete this Guard, so you don't have to
The JCSP method has now been adopted. If the guard is selected by the Alternative, it is now up to the user to then perform the input from the channel manually. However, this gives the added flexibility of having a custom try-catch block for poison, or the use of the new ScopedExtInput class for an in-place extended input.
const AltChanin<DATA_TYPE>& csp::AltChanin< DATA_TYPE >::operator>> | ( | DATA_TYPE & | obj | ) | const [inline] |
Performs a normal input.
Does the same as the input() function but takes a reference not a pointer. It can be used to easily chain sequential inputs as follows:
One2OneChannel<int> chan; AltChanin<int> in = chan.reader(); int a,b; //This: in.input(&a);in.input(&b); //Is the same as this: in >> a >> b;
obj | The variable to input into |
bool csp::AltChanin< DATA_TYPE >::pending | ( | ) | const [inline] |
Checks whether an input would finish immediately on the channel.
This is used as a short form of polling a channel (that would otherwise have to be done using a PRI ALT
with a skip guard)
In practical terms, this method will return true if any of the following are true:
void csp::AltChanin< DATA_TYPE >::input | ( | DATA_TYPE *const | dest | ) | const [inline] |
Performs a normal input.
This simply performs a normal input on the channel, into dest It will not return until the input has completed
dest | The destination of the input. Must not be NULL |
void csp::AltChanin< DATA_TYPE >::read | ( | DATA_TYPE *const | dest | ) | const [inline] |
void csp::AltChanin< 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::AltChanin< 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::AltChanin< DATA_TYPE >::operator== | ( | const csp::AltChanin< 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.
void csp::AltChanin< DATA_TYPE >::extInput | ( | DATA_TYPE *const | dest, | |
PROCESS * | proc, | |||
void(PROCESS::*)() | memberFn | |||
) | const [inline] |
DEPRECATED; A syntax for performing an extended input.
This function takes a destination for the extended input, a class type - which will usually be a process, though it can be any class - and a member function of that class (which should be accessible by Chanin).
The input will be performed, then the function will be called then the outputter will be freed.
You may well wish to look at ScopedExtInput for an alternative way of performing extended inputs.
dest | The destination for the extended input. Must not be NULL | |
proc | The class (not necessarily a process) to call memberFn for | |
memberFn | The member function of proc to call |
void csp::AltChanin< DATA_TYPE >::extInput | ( | DATA_TYPE *const | dest, | |
void(*)() | function | |||
) | const [inline] |
DEPRECATED; Performs an extended input.
This function inputs to dest, then calls function() then frees the outputter. You may well wish to look at ScopedExtInput for an alternative way of performing extended inputs
dest | The destination for the extended input. Must not be NULL | |
function | The function to call during the extended input |