Is it possible to put any type of data or structure into message queues?
By the function definition it looks like I can only pass pointers to char*.
int mq_send( mqd_t mqdes,
const char * msg_ptr,
size_t msg_len,
unsigned int msg_prio );
What if I have a data structure that I want to pass to another asynchronous
process. I want the client to send the message and move on. I want the
server to process the messages out of the queue as it gets time.
“Chris Rose” <rose_chris@excite.com> wrote in message
news:afr80u$see$1@inn.qnx.com…
Is it possible to put any type of data or structure into message queues?
By the function definition it looks like I can only pass pointers to
char*.
int mq_send( mqd_t mqdes,
const char * msg_ptr,
size_t msg_len,
unsigned int msg_prio );
Sure you can, just cast it.
What if I have a data structure that I want to pass to another
asynchronous
process. I want the client to send the message and move on. I want the
server to process the messages out of the queue as it gets time.
You can do this yourself with a “receive” thread it will be more efficient
then using
message queue.
The receive thread queues the messages, and notices the worker thread with
a pulse or other simple IPC. The advantage is the data doesn’t need to be
copied between threads.