10-09-2013 02:58 PM
My application uses User Events to implement a publisher/subscriber pattern.
The publisher is responsible for collecting information from the resource(s) that it manages, and publishes updates to its subscribers. If there are no subscribers, there is no need for the publisher to do any work.
How can the publisher determine how many active registrations ("Register for events") there are on a User Event?
10-09-2013 03:08 PM
I don't think you can unless you somehow send messages back to the producer when something is registered and unregistered. I say just go ahead and publish the data. If nobody is listening, then it will disappear into the ether.
10-09-2013 03:12 PM
@crossrulz wrote:
I don't think you can unless you somehow send messages back to the producer when something is registered and unregistered. I say just go ahead and publish the data. If nobody is listening, then it will disappear into the ether.
Being an anal retentive neat freak, it makes me feel uncomfortable to leave a thread running for no apparent reason.
Are you sure it'll disappear, and not become a memory leak?
10-09-2013 03:22 PM
mflegel wrote:Are you sure it'll disappear, and not become a memory leak?
I am 98% sure. I'm trying to remember the details I was given back at NI Week. Each registration has a FIFO. If the event isn't registered, then the data isn't copied into a FIFO (think FOR loop autoindexing an empty array).
10-09-2013 03:25 PM
Well when you throw the dynamic event it simply queues to any event structures that are registered to recieve the event. If the number of such event queues is zero exactly zero queues copy the event data. In essence you create a zero width buffer at no location. Or, to state it differently- it disapears into the ether.