CSPspEmu.Hle.Threading.Semaphores.HleSemaphore.UpdatedCurrentCount C# (CSharp) Метод

UpdatedCurrentCount() защищенный Метод

protected UpdatedCurrentCount ( ) : int
Результат int
        protected int UpdatedCurrentCount()
        {
            // Selects all the waiting semaphores, that fit the count condition, in a FIFO order.
            var WaitingSemaphoreThreadIterator = WaitingSemaphoreThreadList
                //.Reverse()
                //.Where(WaitingThread => (CurrentCount >= WaitingThread.ExpectedMinimumCount))
                .AsEnumerable()
                //.Reverse()
            ;

            // Reorders the waiting semaphores in a Thread priority order (descending).
            if (SceKernelSemaInfo.Attributes == SemaphoreAttribute.Priority)
            {
                WaitingSemaphoreThreadIterator = WaitingSemaphoreThreadIterator
                    .OrderByDescending(WaitingThread => WaitingThread.HleThread.PriorityValue)
                ;
            }

            int AwakenCount = 0;

            // Iterates all the waiting semaphores in order removing them from list.
            foreach (var WaitingSemaphoreThread in WaitingSemaphoreThreadIterator.ToArray())
            {
                //Console.WriteLine("if (CurrentCount >= WaitingSemaphoreThread.ExpectedMinimumCount) {0}, {1}", CurrentCount, WaitingSemaphoreThread.ExpectedMinimumCount);
                if (CurrentCount >= WaitingSemaphoreThread.ExpectedMinimumCount)
                {
                    CurrentCount -= WaitingSemaphoreThread.ExpectedMinimumCount;
                    WaitingSemaphoreThreadList.Remove(WaitingSemaphoreThread);
                    WaitingSemaphoreThread.WakeUpCallback();
                    AwakenCount++;
                }
            }

            // Updates the statistic about waiting threads.
            SceKernelSemaInfo.NumberOfWaitingThreads = WaitingSemaphoreThreadList.Count;

            return AwakenCount;
        }