Exemplo n.º 1
0
 private void ProcessUnsubscribe(TCriteria criteria, VirtualSubscription virtualSubscription)
 {
     virtualSubscription.DecreaseCounter();
     if (virtualSubscription.NoMoreSubscribers())
     {
         subscriptions.Remove(criteria);
     }
 }
Exemplo n.º 2
0
        public async Task <SubscriptionId> Subscribe(TCriteria criteria, ReactiveActions <TNextArgument> actions)
        {
            var idTask = SafeWait(async() =>
            {
                if (subscriptions.ContainsKey(criteria))
                {
                    subscriptions[criteria].IncreaseCounter();
                    return(subscriptions[criteria].SubscriptionId);
                }

                var disposable          = await SubscribeInternal(criteria, actions).ConfigureAwait(false);
                var generatedId         = generator.GetNewId();
                var virtualSubscription = new VirtualSubscription(generatedId, disposable);
                subscriptions.Add(criteria, virtualSubscription);
                return(generatedId);
            });

            var subscriptionId = await idTask.ConfigureAwait(false);

            return(subscriptionId);
        }