[zeromq-dev] P/Invoke-based CLR access to zeroMQ

Martin Sustrik sustrik at fastmq.com
Fri Feb 20 10:06:06 CET 2009


> Still don't know the code very well, but in case the C API will return 
> the qid and we could decode the message type, we may consider warp the 
> byte[] in a Message class something like:
> 
>     public class Message
>     {
>         public static readonly Message Empty = new Message();
>         public static readonly Message Gap = new Message();
>         public static readonly Message Delimiter = new Message();
> 
>         public byte[] Data { get; set; }
>     }
...
> I'm I lost or this is what you were talking about?

No. You are on a right track. It's only to decided whether above 
"message object" is the right way to go or whether getting message data 
as a return value + queuid & message type by reference would be a better 
solution.

Some random thoughts:

The P/Invoke code would work for both .NET and Mono, right? If so, we 
can actually replace existing .NET implementation by this generic solution.

If byte array is returned from a function, does it mean that the data 
are copied? If so, it may worsen the performance, especially for large 
messages.

If we are going to ship P/Invoke implementation depending on C API, I 
would invest some time in improving the C implementation:

1. Add mask and message types to C API.
2. Improve the performance of C API by avoiding copying message data 
(memcpy) in czmq_receive.

Makes sense?
Martin



More information about the zeromq-dev mailing list