BusAttachment and BusObject concurrency in C++

asked 2015-02-11 03:40:50 -0700

hashok gravatar image

updated 2015-02-11 03:41:52 -0700


There is a "concurrency" argument in the constructor of BusAttachment class which limits the number of "method and signal handlers locally executing".

Q1: Does this argument also affect the concurrency of method handlers of the BusObject registered to the BusAttachment?

Q2: If I don't want to bother with synchronization of BusAttachment listeners and BusObjecrt methods, can I just create BusAttachment with concurrency=1 to have _all_ my callbacks/methods/signals handlers executed sequentially? Is there any pitfalls besides potentially slightly lower performance? Our system is single-core anyway, so additional threads does not influence the performance and we don't plan to block the handlers.

Thank you in advance!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-02-17 14:52:12 -0700

Nikhil Dabhade gravatar image

Hi hashok,

  1. The concurrency is a parameter of the bus attachment. Since the bus object is registered with the bus attachment its concurrency in inherently managed by the bus attachment.

  2. If you do not put in the call to BusAttachment.EnableConcurrentCallbacks() irrespective of the value of concurrency argument (>=1) you will get all messages in sequence. It does make sense to tone down the number to 1 since this makes use of minimum no of threads if you do not plan to do anything special in the handlers.

Hope that helps


edit flag offensive delete publish link more


Thanks for the answers, Nikhil! Let me ask few more questions to clarify better: 1. If the concurrency is 1 and I do call EnableConcurrentCallbacks() followed by some bus method inside my callback, what happens? I suppose, some other callback can be called by bus method despite concurrency is 1, right? 2. Am I right that concurrency affects parallel execution of callbacks in _different_ bus objects? If not, in which case callbacks of the same bus object can be called in parallel (not nested like in EnableConcurrentCallbacks case).

hashok ( 2015-02-17 22:51:08 -0700 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-02-11 03:40:50 -0700

Seen: 148 times

Last updated: Feb 17 '15