示例#1
0
        /// <summary></summary>
        /// <param name="translator">The user specified translation for the event</param>
        /// <param name="capacity">The capacity that should be available before publishing</param>
        /// <returns>true if the value was published, false if there was insufficient
        /// capacity.</returns>
        public bool TryPublishEvent(Func <T, long, T> translator, int capacity)
        {
            if (_ringBuffer.TryNext(capacity, out var sequence))
            {
                TranslateAndPublish(translator, sequence);
                return(true);
            }

            return(false);
        }
示例#2
0
 /// <summary />
 /// <param name="translator">The user specified translation for the event</param>
 /// <param name="capacity">The capacity that should be available before publishing</param>
 /// <returns>true if the value was published, false if there was insufficient
 /// capacity.</returns>
 public bool TryPublishEvent(Func <T, long, T> translator, int capacity)
 {
     try
     {
         long sequence = _ringBuffer.TryNext(capacity);
         TranslateAndPublish(translator, sequence);
         return(true);
     }
     catch (InsufficientCapacityException)
     {
         return(false);
     }
 }