csp::common::WriteOnceProcess< DATA_TYPE > Class Template Reference

Inheritance diagram for csp::common::WriteOnceProcess< DATA_TYPE >:

csp::CSProcess csp::ThreadCSProcess boost::noncopyable List of all members.

Detailed Description

template<typename DATA_TYPE>
class csp::common::WriteOnceProcess< DATA_TYPE >

Writes a given value (passed by pointer) to a channel once.

This process is very similar to WriterProcess. There are two main differences. WriterProcess can write to a channel any number of times, but this process only ever writes once. The more significant difference is that WriterProcess takes the value to be communicated by value. In contrast, this process uses a pointer to a value to communicate. Therefore this process is useful when the data to be communicated is large (or otherwise carries a high copying overhead).

When the process has completed the single write, it simply finishes. It does not poison the channel. If you want to poison the channel afterwards, consider using something like this:

            Run( InSequenceOneThread(new WriteOnceProcess<int>(out,21)) (new ChannelPoisoner(out)) );

To use this process, you will need to include <cppcsp/common/basic.h>

DATA_TYPE Requirements

DATA_TYPE must have a copy constructor, and must meet the requirements of the channels it is being used with.


Public Member Functions

 WriteOnceProcess (const Chanout< DATA_TYPE > &_out, DATA_TYPE const *_value)
 Constructs the process.

Protected Member Functions

void run ()
 You must implement this function to provide the code for your process.


Constructor & Destructor Documentation

template<typename DATA_TYPE>
csp::common::WriteOnceProcess< DATA_TYPE >::WriteOnceProcess ( const Chanout< DATA_TYPE > &  _out,
DATA_TYPE const *  _value 
) [inline]

Constructs the process.

Parameters:
_out The channel to write to
_value The value to write to the channel. This pointer must remain valid for the life time of the process


Member Function Documentation

template<typename DATA_TYPE>
void csp::common::WriteOnceProcess< DATA_TYPE >::run (  )  [inline, protected, virtual]

You must implement this function to provide the code for your process.

When the run method finishes, the process will terminate.

You should not let an uncaught exception cause the end of this function. If it derives from std::exception, it will be caught (although this behaviour should not be relied upon) but otherwise undefined behaviour will result.

Implements csp::ThreadCSProcess.


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