• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 544
  • Last Modified:

critical sections c++

Hi Experts,

I have a list of subscribers that I'm broadcasting an event to.  This list changes size at any time, so of course, before enumerating each listener and broadcasting to each, I need to be in a critical section block.  Is there any other way of doing this?  How expensive is it to be in this block (is there a good way to measure how expensive it is?)  I have a lot of events coming from a real-time device and I want to make sure they happen as fast as possible- while allowing for multiple subscribers for the events......

Thank you!
Mike
0
thready
Asked:
thready
1 Solution
 
TommySzalapskiCommented:
You could go into the critical section block and queue messages for everyone (which should be fairly instant). Then leave the critical section and send all the broadcast messages. This way you send to everyone but are only in the critical section a very short time.
0
 
threadyAuthor Commented:
This is a great answer!  Thanks!  :)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now