Inheritance diagram for csp::common::WriteOnceProcess< DATA_TYPE >:
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>
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. |
csp::common::WriteOnceProcess< DATA_TYPE >::WriteOnceProcess | ( | const Chanout< DATA_TYPE > & | _out, | |
DATA_TYPE const * | _value | |||
) | [inline] |
Constructs the process.
_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 |
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.