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  F. +49 561 804-6277
> 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

Reply via email to