Crate async_subscription_map

Source
Expand description

A subscription map is a self cleaning map of Observables which tracks tasks that want to subscribe to state updates on a certain key. This becomes very useful if you have multiple tasks in your program and you want to wait in one task until the other starts publishing state updates.

It enables you to generically communicate through your whole program by just knowing an identifier, no need to pass observables around - they are created on the fly and only if someone subscribes to them. This is ideal for highly asynchronous and performance critical backend implementations which process and serve data accross multiple protocols and want to cut down latency through communicating in memory.



§Self Cleaning Nature

The subscription map is selfcleaing in the sense that it removes every subscription entry and its data as soon as no one subscribes to it and thus actively preventing memory leaks!

Structs§

SubscriptionMap
A concurrent and self cleaning map of observable values to easily communicate dynamically across tasks.
SubscriptionRef
A transparent wrapper for the underlying subscription in the map which manages the subscription count and removes the observable if no one holds a subscription to it.