Top: Multithreading: message

>     #include <pasync.h>

>     struct message {
>         int id;
>         pintptr param;
>         pintptr result;

>         message(int id, pintptr param = 0);
>     }

A message object or an object of a derived class can be used to post data to message queues (msgqueue) or job queues (jobqueue). Messages are distinguished by a ID that are defined in your application. The user message IDs can be in the range 0 through INT_MAX. Negative values are reserved for internal use by the library.

A simple message can also contain an additional parameter of type pintptr, which is an integer with a size equal to the size of a pointer on the given platform. For more complex message structures you can define classes derived from message - the message queue manager can work with any descendant class as well.

message::message(int id, pintptr param = 0) constructs a message object and assigns id and param fields. param is an additional field that can be used in your application at your own discretion.

int message::id -- this field contains a message ID assigned through the constructor.

pintptr message::param contains the optional parameter.

pintptr message::result -- through this field a message handler can return some simple answer to the sender of this message.

See also: msgqueue, jobqueue, Examples

PTypes home