Beispiel #1
0
        public void NotifySubscriptionPosted()
        {
            int decrementedCounter;

            if (_postingCount == 0 || !InterlockedUtilities.Decrement(location: ref _completedPostingCountdown, minExclusive: 0, result: out decrementedCounter))
            {
                throw new InvalidOperationException();
            }
            else if (decrementedCounter == 0 && _disposeMessageAtEndOfPosting)
            {
                _message?.Dispose();
            }
        }
Beispiel #2
0
 public void Validate()
 {
     if (!IsValidated)
     {
         try {
             OnValidate();
             foreach (var child in Children.EmptyIfNull().SkipNull())
             {
                 child.Validate();
             }
             InterlockedUtilities.Or(ref _helpFlags, 1);
         }
         catch (Exception exception) when(!(exception is MetadataValidationException))
         {
             throw new MetadataValidationException(metadata: this, innerException: exception);
         }
     }
 }
Beispiel #3
0
 void P_ProcessQueue()
 {
     TaskUtilities
     .RunOnDefaultScheduler(
         action:
         () => {
         try {
             __IsThreadProcessingTasks = true;
             for (; ;)
             {
                 var task = default(Task);
                 _tasksQueue
                 .UpdateValue(
                     locTaskList => {
                     if (locTaskList.Count < 1)
                     {
                         return(locTaskList);
                     }
                     else
                     {
                         task = locTaskList[0];
                         return(locTaskList.RemoveAt(0));
                     }
                 });
                 if (task == null)
                 {
                     InterlockedUtilities.Decrement(ref _processQueueRunningCount, 0);
                     break;
                 }
                 else
                 {
                     TryExecuteTask(task);
                 }
             }
         }
         finally {
             __IsThreadProcessingTasks = false;
         }
     },
         ct: CancellationToken.None);
 }
Beispiel #4
0
 LocalSubscriptionStates P_ChangeStateXor(LocalSubscriptionStates state)
 => (LocalSubscriptionStates)InterlockedUtilities.Xor(ref _state, (int)state);