[zeromq-dev] ZMQ - Send std::shared_ptr via inproc pub-sub?

Sergei Nikulov sergey.nikulov at gmail.com
Wed Jun 24 20:14:25 CEST 2020


Inprocess, not interprocess.

Sorry for confusion.

ср, 24 июн. 2020 г., 20:54 Sergei Nikulov <sergey.nikulov at gmail.com>:

> On Wed, Jun 24, 2020 at 8:11 PM Serguei Khasimkhanov
> <SerKhas at hotmail.com> wrote:
> >
> > Hello all,
> >
> > I have a publisher thread that has a bunch of shared_ptrs to large
> chunks of data. Occasionally I want to share some of those shared_ptrs with
> subscribers (for read-only.) The problem is that ZeroMQ only allows sending
> binary data, not C++ objects. How can I accomplish this?
>
> You should serialize your object on publisher side -> send -> receive
> -> deserialize on subscriber.
> There is no other way except you doing some interprocess communication.
> Ref. https://www.google.com/search?q=c%2B%2B+serialization
>
> >
> > I was thinking I could allocate a copy of the shared_ptr on the heap,
> then publish a pointer to it, but since I don't know when the subscribers
> are done using that pointer, I don't know when to deallocate it.
> >
> > - Ser
> > _______________________________________________
> > zeromq-dev mailing list
> > zeromq-dev at lists.zeromq.org
> > https://lists.zeromq.org/mailman/listinfo/zeromq-dev
>
>
>
> --
> Best Regards,
> Sergei Nikulov
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20200624/5b530512/attachment.htm>


More information about the zeromq-dev mailing list