Closed mpokorny closed 6 years ago
As for API, something like the following additions
void vysmaw_add_consumer(vysmaw_handle handle, struct vysmaw_consumer *consumer);
void vysmaw_remove_consumer(vysmaw_handle handle, struct vysmaw_consumer *consumer);
It would still be the application's responsibility in all cases to remove messages from every consumer's queue until a VYSMAW_END_MESSAGE
appears.
The above functions can be called on any "alive" vysmaw handle.
Implementation notes:
vysmaw_start()
ought to be re-implemented to use vysmaw_add_consumer()
; vysmaw_shutdown()
, to use vysmaw_remove_consumer()
.vysmaw_start()
initializes the handle's reference count to 2, which includes one reference by the single end message that must eventually be generated. With the new feature, there will be multiple end messages, one for every consumer that is added during the handle's lifetime.The ability to support multiple consumers for a single vysmaw handle is being removed, so this issue is now effectively moot.
Currently, users need to provide a list of consumers (which effectively means a list of callback functions) when vysmaw starts, and that list is then fixed for the life of the vysmaw handle. What I'm considering is adding the ability to add and remove consumers under the user's control during the lifetime of a handle. Such a feature would allow a user to add new callback functions, each associated with one consumer (and message queue), and remove those the application code has finished using, without starting a new vysmaw handle.