Exemple #1
0
        private void CheckTopics()
        {
            if (Interlocked.Exchange(ref _gcRunning, 1) == 1)
            {
                return;
            }

            foreach (var pair in Topics)
            {
                if (pair.Value.IsExpired)
                {
                    // Only remove the topic if it's expired and we changed the state to dead
                    if (Interlocked.CompareExchange(ref pair.Value.State,
                                                    Topic.TopicState.Dead,
                                                    Topic.TopicState.NoSubscriptions) == Topic.TopicState.NoSubscriptions)
                    {
                        Topic topic;
                        Topics.TryRemove(pair.Key, out topic);
                        _stringMinifier.RemoveUnminified(pair.Key);

                        Trace.TraceInformation("RemoveTopic(" + pair.Key + ")");
                    }
                }
            }

            Interlocked.Exchange(ref _gcRunning, 0);
        }
Exemple #2
0
        private void DestroyTopicCore(string key, Topic topic)
        {
            Topics.TryRemove(key);
            _stringMinifier.RemoveUnminified(key);

            Counters.MessageBusTopicsCurrent.Decrement();

            Trace.TraceInformation("RemoveTopic(" + key + ")");

            if (AfterTopicGarbageCollected != null)
            {
                AfterTopicGarbageCollected(key, topic);
            }
        }