If values are small (<32 bytes) then there are no allocations, as the
message type holds that much data directly.

On Thu, Aug 31, 2017 at 1:54 PM, Patrik VV. <pad...@gmail.com> wrote:

> I'm just curious, how large are those sensor values, how many do you keep
> around, and to how many other robots do you intend to send them?
>
> Could it be premature optimization? Just asking because maybe it's not
> worth the extra effort to make it zero-copy. Just copy and pass ownership
> to ZMQ.
>
> Regards, Patrik
>
> On 31 Aug 2017, at 20:06, Thomas Rodgers <rodg...@twrodgers.com> wrote:
>
> Unfortunately that's not possible, libzmq exposes only a C API, and even
> though it is implemented in C++, it deliberately targets pre-C++11
> compilers.
>
> Further to the 'mark and sweep' idea, or more generally, deferred
> reclamation. You could have the callback place the message to be freed on a
> (possibly lock free, Boost has a handy one) queue and signal a 'reaper'
> thread (waiting on a condition_variable). The reaper thread wakes up,
> reclaims all queued message buffers then returns to waiting.
>
> On Thu, Aug 31, 2017 at 10:55 AM Stephan Opfer <op...@vs.uni-kassel.de>
> wrote:
>
>> > Another, more complicated way, would be to implement a mark&sweep
>> > garbage collector of sorts: instead of freeing the buffer, the callback
>> > you register with zmq_msg_init_data would mark the buffer as done (in a
>> > thread safe way!). Then your application's garbage collector can sweep
>> > it.
>>
>> It would be nice, if I could pass over a copy  of (not reference or
>> pointer to) a shared_ptr that owns the buffer, but with the call back and
>> the "void * hint" this wasn't possible for me.
>>
>> --
>> Distributed Systems Research Group
>> Stephan Opfer  T. +49 561 804-6280 <+49%20561%208046280>  F. +49 561
>> 804-6277 <+49%20561%208046277>
>> Univ. Kassel,  FB 16,  Wilhelmshöher Allee 73,  D-34121 Kassel
>> WWW: http://www.uni-kassel.de/go/vs_stephan-opfer/
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev@lists.zeromq.org
>> https://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev@lists.zeromq.org
> https://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev@lists.zeromq.org
> https://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
_______________________________________________
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
https://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to