Use of the MessageParticle Class

If a porthole is of type message, its particles are objects of the class MessageParticle. A MessageParticle is simply a particle whose data field is an Envelope, which means that it can hold a Message in the same way that Envelope objects do.

Many methods of the Particle class are redefined in the MessageParticle class to cause a run-time error. For example, it is illegal to send an integer, floating or complex number to the particle with the << operator. The conversion operators (conversion to type int, double, or Complex) return errors by default, but can be made legal by redefining the asInt, asFloat, or asComplex methods for a specific message type.

The principal operations on MessageParticle objects are << with an argument of type Envelope, to load a message into the particle, and getMessage(Envelope&), to transfer message contents from the particle into a user-supplied message. The getMessage method removes the message contents from the particle. In cases where the destructive behavior of getMessage cannot be tolerated, an alternative interface, accessMessage(Envelope&), is provided. It does not remove the message contents from the particle. Promiscuous use of accessMessage in systems with large-sized messages can increase the amount of virtual memory to be reserved (though all message will be deleted eventually).