Send pulse with pointer as the data


I want to send a pulse to a channel, and attached to that pulse is a pointer to an object. I cannot find where to insert the pointer.

I am using MsgSendPulse( CoID, 10, MY_PULSE_CODE, … ), where the last field is an integer value. Do I have to send an event instead, that has been defined as a pulse?

The two channels are in the same process; they are two different threads that are communicating together.



While it’s not recommended that you pass pointer in the pulse, you certainly can do so if they are threads in the same process.

Just fill the 4 byte integer value out with the address the pointer points to (Ie put the value of ‘&fooObject’ into the integer value in the pulse). The on the receiving side, copy that address into your pointer on the other thread and voila, you have passed the pointer. Just make sure to document what you are doing with the pointer VERY well.

It’s also guaranteed to be very non-portable if QNX ever moves to 64 bit addressing and only leaves a 32 bit integer value in the pulse…


The pointer could also be to an object in shared memory. If you can restructure this to send an index into an array, possibly an array of pointers, it would be more portable.

Not sure what you are trying to do. One idiom I find very useful though is to put an opaque pointer in a pulse that is delivered via MsgDeliverEvent(). The pointer is meaningful only to the server, but the client which receives the pulse stuffs the pointer received into the message that it sends to the server, the server then has a pointer directly to the internal object that the pulse referred to.

This idiom is very useful where the pulse is a notification to the client that an event of interest has occurred on a particular object (think select()).

The value member is where the pointer is stored…