Ejemplo n.º 1
0
 public virtual bool AddEvent(string key, Topic topic)
 {
     lock (EventKeys)
     {
         return EventKeys.Add(key);
     }
 }
Ejemplo n.º 2
0
        public override bool AddEvent(string eventKey, Topic topic)
        {
            lock (_lockObj)
            {
                // O(n), but small n and it's not common
                var index = _cursors.FindIndex(c => c.Key == eventKey);
                if (index == -1)
                {
                    _cursors.Add(new Cursor(eventKey, GetMessageId(topic), _stringMinifier.Minify(eventKey)));

                    _cursorTopics.Add(topic);

                    return true;
                }

                return false;
            }
        }
Ejemplo n.º 3
0
        private void ScheduleTopic(Topic topic)
        {
            try
            {
                topic.SubscriptionLock.EnterReadLock();

                for (int i = 0; i < topic.Subscriptions.Count; i++)
                {
                    ISubscription subscription = topic.Subscriptions[i];
                    _broker.Schedule(subscription);
                }
            }
            finally
            {
                topic.SubscriptionLock.ExitReadLock();
            }
        }
Ejemplo n.º 4
0
        private static ulong GetMessageId(Topic topic)
        {
            if (topic == null)
            {
                return 0;
            }

            return topic.Store.GetMessageCount();
        }
Ejemplo n.º 5
0
 public override void SetEventTopic(string eventKey, Topic topic)
 {
     lock (_lockObj)
     {
         // O(n), but small n and it's not common
         var index = _cursors.FindIndex(c => c.Key == eventKey);
         if (index != -1)
         {
             _cursorTopics[index] = topic;
         }
     }
 }
Ejemplo n.º 6
0
 public virtual void SetEventTopic(string key, Topic topic)
 {
     lock (EventKeys)
     {
         EventKeys.Add(key);
     }
 }