Beispiel #1
0
        public void PublishEvents <A, B, C>(IEventTranslatorThreeArg <T, A, B, C> translator, int batchStartsAt, int batchSize, A[] arg0, B[] arg1, C[] arg2)
        {
            CheckBounds(arg0, arg1, arg2, batchStartsAt, batchSize);
            long finalSequence = _fields.Sequencer.Next(batchSize);

            TranslateAndPublishBatch(translator, arg0, arg1, arg2, batchStartsAt, batchSize, finalSequence);
        }
Beispiel #2
0
        public void PublishEvents <TArg0, TArg1, TArg2>(IEventTranslatorThreeArg <TEvent, TArg0, TArg1, TArg2> translator, int batchStartsAt, int batchSize, TArg0[] arg0, TArg1[] arg1, TArg2[] arg2)
        {
            CheckBounds(arg0, arg1, arg2, batchStartsAt, batchSize);
            var finalSequence = Sequencer.Next(batchSize);

            TranslateAndPublishBatch(translator, arg0, arg1, arg2, batchStartsAt, batchSize, finalSequence);
        }
Beispiel #3
0
        /// <summary>
        /// <see cref="IEventSink{T}.TryPublishEvent{A,B,C}(IEventTranslatorThreeArg{T,A,B,C},A,B,C)"/>
        /// </summary>
        public bool TryPublishEvent <A, B, C>(IEventTranslatorThreeArg <T, A, B, C> translator, A arg0, B arg1, C arg2)
        {
            if (_fields.Sequencer.TryNext(out var sequence))
            {
                TranslateAndPublish(translator, sequence, arg0, arg1, arg2);
                return(true);
            }

            return(false);
        }
Beispiel #4
0
        /// <summary>
        /// <see cref="IEventSink{T}.TryPublishEvents{A,B,C}(IEventTranslatorThreeArg{T,A,B,C},int,int,A[],B[],C[])"/>
        /// </summary>
        public bool TryPublishEvents <A, B, C>(IEventTranslatorThreeArg <T, A, B, C> translator, int batchStartsAt, int batchSize, A[] arg0, B[] arg1, C[] arg2)
        {
            CheckBounds(arg0, arg1, arg2, batchStartsAt, batchSize);

            if (_fields.Sequencer.TryNext(batchSize, out var finalSequence))
            {
                TranslateAndPublishBatch(translator, arg0, arg1, arg2, batchStartsAt, batchSize, finalSequence);
                return(true);
            }

            return(false);
        }
Beispiel #5
0
 private void TranslateAndPublish <A, B, C>(IEventTranslatorThreeArg <T, A, B, C> translator, long sequence,
                                            A arg0, B arg1, C arg2)
 {
     try
     {
         translator.TranslateTo(this[sequence], sequence, arg0, arg1, arg2);
     }
     finally
     {
         _fields.Sequencer.Publish(sequence);
     }
 }
Beispiel #6
0
 public bool TryPublishEvent <TArg0, TArg1, TArg2>(IEventTranslatorThreeArg <TEvent, TArg0, TArg1, TArg2> translator, TArg0 arg0, TArg1 arg1, TArg2 arg2)
 {
     try
     {
         Sequencer.TryNext(out long sequence);
         TranslateAndPublish(translator, sequence, arg0, arg1, arg2);
         return(true);
     }
     catch (InsufficientCapacityException e)
     {
         return(false);
     }
 }
Beispiel #7
0
 public bool TryPublishEvent <A, B, C>(IEventTranslatorThreeArg <T, A, B, C> translator, A arg0, B arg1, C arg2)
 {
     try
     {
         long sequence = _fields.Sequencer.TryNext();
         TranslateAndPublish(translator, sequence, arg0, arg1, arg2);
         return(true);
     }
     catch (InsufficientCapacityException)
     {
         return(false);
     }
 }
Beispiel #8
0
 private void TranslateAndPublish <TArg0, TArg1, TArg2>(
     IEventTranslatorThreeArg <TEvent, TArg0, TArg1, TArg2> translator,
     long sequence,
     TArg0 arg0, TArg1 arg1, TArg2 arg2)
 {
     try
     {
         translator.TranslateTo(Get(sequence), sequence, arg0, arg1, arg2);
     }
     finally
     {
         Sequencer.Publish(sequence);
     }
 }
Beispiel #9
0
 public bool TryPublishEvents <A, B, C>(IEventTranslatorThreeArg <T, A, B, C> translator, int batchStartsAt, int batchSize, A[] arg0, B[] arg1, C[] arg2)
 {
     CheckBounds(arg0, arg1, arg2, batchStartsAt, batchSize);
     try
     {
         long finalSequence = _fields.Sequencer.TryNext(batchSize);
         TranslateAndPublishBatch(translator, arg0, arg1, arg2, batchStartsAt, batchSize, finalSequence);
         return(true);
     }
     catch (InsufficientCapacityException)
     {
         return(false);
     }
 }
Beispiel #10
0
 public bool TryPublishEvents <TArg0, TArg1, TArg2>(IEventTranslatorThreeArg <TEvent, TArg0, TArg1, TArg2> translator, int batchStartsAt, int batchSize, TArg0[] arg0, TArg1[] arg1, TArg2[] arg2)
 {
     CheckBounds(arg0, arg1, arg2, batchStartsAt, batchSize);
     try
     {
         if (Sequencer.TryNext(batchSize, out long finalSequence))
         {
             TranslateAndPublishBatch(translator, arg0, arg1, arg2, batchStartsAt, batchSize, finalSequence);
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (InsufficientCapacityException e)
     {
         return(false);
     }
 }
Beispiel #11
0
        private void TranslateAndPublishBatch <A, B, C>(IEventTranslatorThreeArg <T, A, B, C> translator,
                                                        A[] arg0, B[] arg1, C[] arg2, int batchStartsAt,
                                                        int batchSize, long finalSequence)
        {
            long initialSequence = finalSequence - (batchSize - 1);

            try
            {
                long sequence    = initialSequence;
                int  batchEndsAt = batchStartsAt + batchSize;
                for (int i = batchStartsAt; i < batchEndsAt; i++)
                {
                    translator.TranslateTo(this[sequence], sequence++, arg0[i], arg1[i], arg2[i]);
                }
            }
            finally
            {
                _fields.Sequencer.Publish(initialSequence, finalSequence);
            }
        }
Beispiel #12
0
        private void TranslateAndPublishBatch <TArg0, TArg1, TArg2>(IEventTranslatorThreeArg <TEvent, TArg0, TArg1, TArg2> translator,
                                                                    TArg0[] arg0, TArg1[] arg1, TArg2[] arg2,
                                                                    int batchStartsAt, int batchSize,
                                                                    long finalSequence)
        {
            var initialSequence = finalSequence - (batchSize - 1);

            try
            {
                var sequence    = initialSequence;
                var batchEndsAt = batchStartsAt + batchSize;
                for (int i = batchStartsAt; i < batchEndsAt; i++)
                {
                    translator.TranslateTo(Get(sequence), sequence++, arg0[i], arg1[i], arg2[i]);
                }
            }
            finally
            {
                Sequencer.Publish(initialSequence, finalSequence);
            }
        }
Beispiel #13
0
 public bool TryPublishEvents <A, B, C>(IEventTranslatorThreeArg <T, A, B, C> translator, A[] arg0, B[] arg1, C[] arg2)
 {
     return(TryPublishEvents(translator, 0, arg0.Length, arg0, arg1, arg2));
 }
Beispiel #14
0
 /// <summary>
 /// Publish an event to the ring buffer.
 /// </summary>
 /// <typeparam name="A">Class of the user supplied argument.</typeparam>
 /// <typeparam name="B">Class of the user supplied argument.</typeparam>
 /// <typeparam name="C">Class of the user supplied argument.</typeparam>
 /// <param name="eventTranslator">the translator that will load data into the event.</param>
 /// <param name="arg0">The first argument to load into the event</param>
 /// <param name="arg1">The second argument to load into the event</param>
 /// <param name="arg2">The third argument to load into the event</param>
 public void PublishEvent <A, B, C>(IEventTranslatorThreeArg <T, A, B, C> eventTranslator, A arg0, B arg1, C arg2) => _ringBuffer.PublishEvent(eventTranslator, arg0, arg1, arg2);
Beispiel #15
0
 public void PublishEvents <A, B, C>(IEventTranslatorThreeArg <T, A, B, C> translator, A[] arg0, B[] arg1, C[] arg2)
 {
     PublishEvents(translator, 0, arg0.Length, arg0, arg1, arg2);
 }
Beispiel #16
0
        public void PublishEvent <TArg0, TArg1, TArg2>(IEventTranslatorThreeArg <TEvent, TArg0, TArg1, TArg2> translator, TArg0 arg0, TArg1 arg1, TArg2 arg2)
        {
            var sequence = Sequencer.Next();

            TranslateAndPublish(translator, sequence, arg0, arg1, arg2);
        }
Beispiel #17
0
        public void PublishEvent <A, B, C>(IEventTranslatorThreeArg <T, A, B, C> translator, A arg0, B arg1, C arg2)
        {
            long sequence = _fields.Sequencer.Next();

            TranslateAndPublish(translator, sequence, arg0, arg1, arg2);
        }
Beispiel #18
0
 public void PublishEvent <TArg0, TArg1, TArg2>(IEventTranslatorThreeArg <TEvent, TArg0, TArg1, TArg2> translator, TArg0 arg0, TArg1 arg1, TArg2 arg2)
 {
     throw new NotImplementedException();
 }
Beispiel #19
0
 public bool TryPublishEvents <TArg0, TArg1, TArg2>(IEventTranslatorThreeArg <TEvent, TArg0, TArg1, TArg2> translator, TArg0[] arg0, TArg1[] arg1, TArg2[] arg2)
 {
     return(TryPublishEvents(translator, 0, arg0.Length, arg0, arg1, arg2));
 }
Beispiel #20
0
 public void PublishEvents <TArg0, TArg1, TArg2>(IEventTranslatorThreeArg <TEvent, TArg0, TArg1, TArg2> translator, TArg0[] arg0, TArg1[] arg1, TArg2[] arg2)
 {
     PublishEvents(translator, 0, arg0.Length, arg0, arg1, arg2);
 }
Beispiel #21
0
 /// <summary>
 /// Publish an event to the ring buffer.
 /// </summary>
 /// <typeparam name="TArg0">Class of the user supplied argument.</typeparam>
 /// <typeparam name="TArg1">Class of the user supplied argument.</typeparam>
 /// <typeparam name="TArg2">Class of the user supplied argument.</typeparam>
 /// <param name="eventTranslator">the translator that will load data into the event.</param>
 /// <param name="arg0">The first argument to load into the event</param>
 /// <param name="arg1">The second argument to load into the event</param>
 /// <param name="arg2">The third argument to load into the event</param>
 public void PublishEvent <TArg0, TArg1, TArg2>(IEventTranslatorThreeArg <T, TArg0, TArg1, TArg2> eventTranslator, TArg0 arg0,
                                                TArg1 arg1, TArg2 arg2)
 {
     _ringBuffer.PublishEvent(eventTranslator, arg0, arg1, arg2);
 }
Beispiel #22
0
 public bool TryPublishEvents <TArg0, TArg1, TArg2>(IEventTranslatorThreeArg <TEvent, TArg0, TArg1, TArg2> translator, int batchStartsAt, int batchSize, TArg0[] arg0, TArg1[] arg1, TArg2[] arg2)
 {
     throw new NotImplementedException();
 }