C++ lcm::LCM singleton needed?

77 views
Skip to first unread message

Tom O'Reilly

unread,
Sep 11, 2017, 2:29:58 PM9/11/17
to Lightweight Communications and Marshalling
I have a multi-threaded C++ application; components in individual threads need to access LCM. I'm hoping to avoid the multi-threaded Singleton pattern (I'm stuck with the C++98).

Is it wasteful of network or other resources if each component that needs LCM simply calls the LCM constructor, with all components using the same LCM URL argument?  

Thanks
Tom

Jonathan Bendes

unread,
Sep 11, 2017, 3:58:00 PM9/11/17
to lcm-...@googlegroups.com
Hi Tom,

I believe LCM is set up so that you can publish from whatever thread you happen to be in with the same LCM object. Someone else might be able to guarantee that, but looking at lcm.c:publish it seems to be locking around the queue of messages to send. If this is the case, you should only need one object if you just plan on publishing from the various threads.

Best,
Jonathan

--
You received this message because you are subscribed to the Google Groups "Lightweight Communications and Marshalling" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lcm-users+...@googlegroups.com.
To post to this group, send email to lcm-...@googlegroups.com.
Visit this group at https://groups.google.com/group/lcm-users.
For more options, visit https://groups.google.com/d/optout.
--
Jonathan Bendes
Vice President of Product Development
Reply all
Reply to author
Forward
0 new messages