public static async Task AwaitDequeue3(ISequencerUC sequencer, IConcurrentQueueNotifier <string> notifier)
        {
            await sequencer.PointAsync(SeqPointTypeUC.Match, Insert3ItemsThrottleTestEnum.EnqueuedItemsAsyncBegin);

            string item;

            await notifier.EnqueuedItemsAsync();

            if (!notifier.TryDequeu(out item))
            {
                throw new Exception("Expected data");
            }
            await sequencer.PointAsync(SeqPointTypeUC.Match, Insert3ItemsThrottleTestEnum.EnqueuedItemsAsyncDataItem, item);

            await notifier.EnqueuedItemsAsync();

            if (!notifier.TryDequeu(out item))
            {
                throw new Exception("Expected data");
            }
            await sequencer.PointAsync(SeqPointTypeUC.Match, Insert3ItemsThrottleTestEnum.EnqueuedItemsAsyncDataItem, item);

            await notifier.EnqueuedItemsAsync();

            if (!notifier.TryDequeu(out item))
            {
                throw new Exception("Expected data");
            }
            await sequencer.PointAsync(SeqPointTypeUC.Match, Insert3ItemsThrottleTestEnum.EnqueuedItemsAsyncDataItem, item);

            await sequencer.PointAsync(SeqPointTypeUC.Match, Insert3ItemsThrottleTestEnum.EnqueuedItemsAsyncEnd);
        }
        public static async Task AwaitEnqueuedData(ISequencerUC sequencer, IConcurrentQueueNotifier <string> notifier)
        {
            await sequencer.PointAsync(SeqPointTypeUC.Match, AwaitAlreadyEnqueuedDataEnum.EnqueuedItemsAsyncBegin);

            await notifier.EnqueuedItemsAsync();

            await sequencer.PointAsync(SeqPointTypeUC.Match, AwaitAlreadyEnqueuedDataEnum.EnqueuedItemsAsyncEnd);
        }
Example #3
0
        public static async Task Enque2Items(ISequencerUC sequencer, IConcurrentQueueNotifier <string> notifier)
        {
            await sequencer.PointAsync(SeqPointTypeUC.Match, AwaitAheadOfDataEnum.Enqueue2ItemsBegin);

            await notifier.EnqueueAsync("A");

            await sequencer.PointAsync(SeqPointTypeUC.Match, AwaitAheadOfDataEnum.Enqueue2ItemsA);

            await sequencer.PointAsync(SeqPointTypeUC.Match, AwaitAheadOfDataEnum.Enqueue2ItemsEnd);
        }
Example #4
0
        public static async Task AwaitAhedOfData(ISequencerUC sequencer, IConcurrentQueueNotifier <string> notifier)
        {
            await sequencer.PointAsync(SeqPointTypeUC.Match, AwaitAheadOfDataEnum.EnqueuedItemsAsyncBegin);

            Task t = notifier.EnqueuedItemsAsync();
            await sequencer.PointAsync(SeqPointTypeUC.Match, AwaitAheadOfDataEnum.EnqueuedItemsAsyncAwaiting, t);

            await t;

            await sequencer.PointAsync(SeqPointTypeUC.Match, AwaitAheadOfDataEnum.EnqueuedItemsAsyncEnd);
        }
        private static async Task ConcurrentSequencingWorker(IAsyncLockUC Lock, ISequencerUC sequencer)
        {
            await sequencer.PointAsync(SeqPointTypeUC.Match, ConcurrentSequencingPhase.Begin);

            await sequencer.PointAsync(SeqPointTypeUC.Notify, ConcurrentSequencingPhase.EnteringSimpleLock, Interlocked.Increment(ref StepConcurrentSequencing));

            using (await Lock.Enter())
            {
                await sequencer.PointAsync(SeqPointTypeUC.Match, ConcurrentSequencingPhase.Locked, Interlocked.Decrement(ref StepConcurrentSequencing));

                await sequencer.PointAsync(SeqPointTypeUC.Notify, ConcurrentSequencingPhase.LockedNotify, Interlocked.Add(ref StepConcurrentSequencing, 0));
            }
            await sequencer.PointAsync(SeqPointTypeUC.Match, ConcurrentSequencingPhase.End);
        }
Example #6
0
        private static async Task ConcurrentSequencingAsyncWorker(SpinLockUC spinLock, ISequencerUC sequencer)
        {
            await sequencer.PointAsync(SeqPointTypeUC.Match, ConcurrentSequencingPhaseAsync.Begin);

            await sequencer.PointAsync(SeqPointTypeUC.Notify, ConcurrentSequencingPhaseAsync.EnteringSpinLock, Interlocked.Increment(ref StepConcurrentSequencingAsync));

            using (spinLock.Enter())
            {
                await sequencer.PointAsync(SeqPointTypeUC.Match, ConcurrentSequencingPhaseAsync.Locked, Interlocked.Decrement(ref StepConcurrentSequencingAsync));

                await sequencer.PointAsync(SeqPointTypeUC.Notify, ConcurrentSequencingPhaseAsync.LockedNotify, Interlocked.Add(ref StepConcurrentSequencingAsync, 0));
            }
            await sequencer.PointAsync(SeqPointTypeUC.Match, ConcurrentSequencingPhaseAsync.End);
        }
        public static async Task Insert3ItemsThrottle(ISequencerUC sequencer, IConcurrentQueueNotifier <string> notifier)
        {
            await sequencer.PointAsync(SeqPointTypeUC.Match, Insert3ItemsThrottleTestEnum.Enqueue3Items_Begin);

            await notifier.EnqueueAsync("A");

            await sequencer.PointAsync(SeqPointTypeUC.Match, Insert3ItemsThrottleTestEnum.Enqueue3Items_A);

            await notifier.EnqueueAsync("B");

            await sequencer.PointAsync(SeqPointTypeUC.Match, Insert3ItemsThrottleTestEnum.Enqueue3Items_B);

            Task result = notifier.EnqueueAsync("C");
            await sequencer.PointAsync(SeqPointTypeUC.Match, Insert3ItemsThrottleTestEnum.Enqueue3Items_C_Throttle, result);

            await result;

            await sequencer.PointAsync(SeqPointTypeUC.Match, Insert3ItemsThrottleTestEnum.Enqueue3Items_End);
        }
        void Point <TEnum>(this  ISequencerUC sequencer,
                           SeqPointTypeUC seqPointTypeUC,
                           TEnum registration,
                           object arg = null,
                           Action <object> injectContinuation = null)
            where TEnum : struct
        {
            var rslt = sequencer.PointAsync(seqPointTypeUC, registration, arg, injectContinuation);

            rslt.GetResult();            //sync waiting unless completed awaiter was provided
        }
Example #9
0
 PointAsync <TEnum>(this  ISequencerUC sequencer,
                    SeqPointTypeUC seqPointTypeUC,
                    TEnum registration,
                    object arg = null,
                    Action <object> injectContinuation = null)
     where TEnum : struct
 {
     return
         (sequencer
          .PointAsync(seqPointTypeUC,
                      registration,
                      () => true,
                      arg,
                      injectContinuation)
         );
 }