System.Collections.Generic.Queue.Dequeue()

Here are the examples of the csharp api System.Collections.Generic.Queue.Dequeue() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

4232 Examples 7

19 View Source File : GameUtils.cs
License : Apache License 2.0
Project Creator : AantCoder

private static void DialodQueueGoNext()
        {
            lock (DialodQueue)
            {
                if (DialodQueue.Count > 0)
                {
                    DialodQueue.Dequeue()();
                }
                else
                {
                    DialodShowing = false;
                }
            }
        }

19 View Source File : OvrAvatarTextureCopyManager.cs
License : MIT License
Project Creator : absurd-joy

public void Update()
    {
        if (texturesToCopy.Count == 0)
        {
            return;
        }

        lock (texturesToCopy)
        {
            for (int i = 0; i < Mathf.Min(COPIES_PER_FRAME, texturesToCopy.Count); ++i)
            {
                CopyTexture(texturesToCopy.Dequeue());
            }
        }
    }

19 View Source File : Shell.cs
License : MIT License
Project Creator : 5minlab

public static void Update() {
            while (Instance.m_commandQueue.Count > 0) {
                QueuedCommand cmd = Instance.m_commandQueue.Dequeue();
                cmd.command.m_callback(cmd.args);
            }
        }

19 View Source File : ConnectionManager.cs
License : MIT License
Project Creator : a11s

private void RemoveCloseRequests()
        {
            while (CloseRequestQueue.Count > 0)
            {
                int sid = CloseRequestQueue.Dequeue();
                if (ConnDict.TryGetValue(sid, out var p))
                {
                    RecycleSession(p.SessionId);//归还
                    p.OnTimeout(DateTime.MinValue, TimeSpan.MinValue);
                }
            }
        }

19 View Source File : MultiwayTree{T}.cs
License : MIT License
Project Creator : 7Bytes-Studio

private void _BreadthFirstTraverse(MultiwayTreeNode<T> currentNode, Action<MultiwayTreeNode<T>> breadthFirstTraverse)
        {
            Queue<MultiwayTreeNode<T>> childQueue = new Queue<MultiwayTreeNode<T>>();

            foreach (var child in currentNode)
            {
                if (null != breadthFirstTraverse)
                {
                    breadthFirstTraverse.Invoke(child);
                }
                childQueue.Enqueue(child);
            }

            while (0 < childQueue.Count)
            {
                var node = childQueue.Dequeue();
                _BreadthFirstTraverse(node, breadthFirstTraverse);
            }

            return;
        }

19 View Source File : DownloadManager.cs
License : MIT License
Project Creator : 404Lcc

public void DownloadTask()
        {
            lock (lockObject)
            {
                runnings.Add(Thread.CurrentThread, null);
            }
            while (true)
            {
                DownloadFile downloadFile = null;
                lock (lockObject)
                {
                    if (readyQueue.Count > 0)
                    {
                        downloadFile = readyQueue.Dequeue();
                        runnings[Thread.CurrentThread] = downloadFile;
                    }
                }
                if (downloadFile == null) break;
                downloadFile.Download();
                if (downloadFile.state == DownloadState.Complete)
                {
                    lock (lockObject)
                    {
                        completeList.Add(downloadFile.downloadData);
                        runnings[Thread.CurrentThread] = null;
                    }
                }
                else if (downloadFile.state == DownloadState.Error)
                {
                    lock (lockObject)
                    {
                        if (downloadFile.count == 5)
                        {
                            errorList.Add(downloadFile);
                        }
                        else
                        {
                            readyQueue.Enqueue(downloadFile);
                        }
                    }
                    break;
                }
                else
                {
                    break;
                }
            }
        }

19 View Source File : GameObjectPool.cs
License : Apache License 2.0
Project Creator : abist-co-ltd

public GameObject GetGameObject(string objectIdentifier, Vector3 position, Quaternion rotation)
        {
            GameObject obj = null;
            GameObjectCreator creator = null;
            if (_creators.ContainsKey(objectIdentifier))
            {
                creator = _creators[objectIdentifier];
            }
            else
            {
                Debug.Log("Unable to create a GameObject for object ID '" + objectIdentifier + "' because no IGameObjectCreator implementation can be found for it.");
                return null;
            }

            EnsureListForObjectID(objectIdentifier);

            Queue<GameObject> objects = _pool[objectIdentifier];

            if (objects.Count > 0)
            {
                obj = objects.Dequeue();
            }
            else
            {
                obj = creator.Instantiate();
            }

            if (obj != null)
            {
                creator.PrepareForUse(obj);
                obj.SetActive(true);
            }

            return obj;
        }

19 View Source File : SftpWinForm.cs
License : Apache License 2.0
Project Creator : 214175590

private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (COPY_QUEUE.Count > 0)
            {
                string[] items = null;
                string path1, path2;
                string currDir = getCurrDir();
                for (int i = 0, k = COPY_QUEUE.Count; i < k; i++)
                {
                    items = COPY_QUEUE.Dequeue();
                    path1 = items[0] + items[1];
                    path2 = currDir + items[1];
                    if (Utils.IsDir(path1))
                    {
                        Utils.CopyDir(path1, path2);
                    }
                    else
                    {
                        new FileInfo(path1).CopyTo(path2);
                    }
                }
                pasteToolStripMenuItem.Enabled = false;

                ThreadPool.QueueUserWorkItem((a) =>
                {
                    Thread.Sleep(500);
                    // 刷新
                    LoadDirFilesToListView(dir);
                });
            }
        }

19 View Source File : OvrAvatarSDKManager.cs
License : MIT License
Project Creator : absurd-joy

void Update()
	{
	    if (Instance == null)
	    {
	        return;
	    }
#if AVATAR_DEBUG
        // Call before ovrAvatarMessage_Pop which flushes the state
        CAPI.ovrAvatar_DrawDebugLines();
#endif

        // Dispatch waiting avatar spec request
        if (avatarSpecificationQueue.Count > 0 &&
	        (avatarSpecRequestAvailable ||
	        Time.time - lastDispatchedAvatarSpecRequestTime >= AVATAR_SPEC_REQUEST_TIMEOUT))
	    {
	        avatarSpecRequestAvailable = false;
	        AvatarSpecRequestParams avatarSpec = avatarSpecificationQueue.Dequeue();
	        DispatchAvatarSpecificationRequest(avatarSpec);
            lastDispatchedAvatarSpecRequestTime = Time.time;
            AvatarLogger.Log("Avatar spec request dispatched: " + avatarSpec._userId);
        }

        IntPtr message = CAPI.ovrAvatarMessage_Pop();
        if (message == IntPtr.Zero)
        {
            return;
        }

        ovrAvatarMessageType messageType = CAPI.ovrAvatarMessage_GetType(message);
        switch (messageType)
        {
            case ovrAvatarMessageType.replacedetLoaded:
                {
                    ovrAvatarMessage_replacedetLoaded replacedetMessage = CAPI.ovrAvatarMessage_GetreplacedetLoaded(message);
                    IntPtr replacedet = replacedetMessage.replacedet;
                    UInt64 replacedetID = replacedetMessage.replacedetID;
                    ovrAvatarreplacedetType replacedetType = CAPI.ovrAvatarreplacedet_GetType(replacedet);
                    OvrAvatarreplacedet replacedetData = null;
                    IntPtr avatarOwner = IntPtr.Zero;

                    switch (replacedetType)
                    {
                        case ovrAvatarreplacedetType.Mesh:
                            replacedetData = new OvrAvatarreplacedetMesh(replacedetID, replacedet, ovrAvatarreplacedetType.Mesh);
                            break;
                        case ovrAvatarreplacedetType.Texture:
                            replacedetData = new OvrAvatarreplacedetTexture(replacedetID, replacedet);
                            break;
                        case ovrAvatarreplacedetType.Material:
                            replacedetData = new OvrAvatarreplacedetMaterial(replacedetID, replacedet);
                            break;
                        case ovrAvatarreplacedetType.CombinedMesh:
                            avatarOwner = CAPI.ovrAvatarreplacedet_GetAvatar(replacedet);
                            replacedetData = new OvrAvatarreplacedetMesh(replacedetID, replacedet, ovrAvatarreplacedetType.CombinedMesh);
                            break;
                        case ovrAvatarreplacedetType.FailedLoad:
                            AvatarLogger.LogWarning("replacedet failed to load from SDK " + replacedetID);
                            break;
                        default:
                            throw new NotImplementedException(string.Format("Unsupported replacedet type format {0}", replacedetType.ToString()));
                    }

                    HashSet<replacedetLoadedCallback> callbackSet;
                    if (replacedetType == ovrAvatarreplacedetType.CombinedMesh)
                    {
                        if (!replacedetCache.ContainsKey(replacedetID))
                        {
                            replacedetCache.Add(replacedetID, replacedetData);
                        }

                        combinedMeshLoadedCallback callback;
                        if (combinedMeshLoadedCallbacks.TryGetValue(avatarOwner, out callback))
                        {
                            callback(replacedet);
                            combinedMeshLoadedCallbacks.Remove(avatarOwner);
                        }
                        else
                        {
                            AvatarLogger.LogWarning("Loaded a combined mesh with no owner: " + replacedetMessage.replacedetID);
                        }
                    }
                    else
                    {
                        if (replacedetData != null && replacedetLoadedCallbacks.TryGetValue(replacedetMessage.replacedetID, out callbackSet))
                        {
                            replacedetCache.Add(replacedetID, replacedetData);

                            foreach (var callback in callbackSet)
                            {
                                callback(replacedetData);
                            }

                            replacedetLoadedCallbacks.Remove(replacedetMessage.replacedetID);
                        }
                    }
                    break;
                }
            case ovrAvatarMessageType.AvatarSpecification:
            {
                    avatarSpecRequestAvailable = true;
                    ovrAvatarMessage_AvatarSpecification spec = CAPI.ovrAvatarMessage_GetAvatarSpecification(message);
                    HashSet<specificationCallback> callbackSet;
                    if (specificationCallbacks.TryGetValue(spec.oculusUserID, out callbackSet))
                    {
                        foreach (var callback in callbackSet)
                        {
                            callback(spec.avatarSpec);
                        }

                        specificationCallbacks.Remove(spec.oculusUserID);
                    }
                    else
                    {
                        AvatarLogger.LogWarning("Error, got an avatar specification callback from a user id we don't have a record for: " + spec.oculusUserID);
                    }
                    break;
                }
            default:
                throw new NotImplementedException("Unhandled ovrAvatarMessageType: " + messageType);
        }
        CAPI.ovrAvatarMessage_Free(message);
    }

19 View Source File : SftpForm.cs
License : Apache License 2.0
Project Creator : 214175590

private void getTransferItem(string flag, GereplacedemCallback callback)
        {
            TransferItem item = null;
            this.BeginInvoke((MethodInvoker)delegate()
            {
                if (flag == "L2R")
                {
                    TransferItem obj = localQueue.Count > 0 ? localQueue.Dequeue() : null;
                    if (null != obj)
                    {
                        if (checkTransferItem(obj))
                        {
                            item = obj;
                            localList.Add(item);
                            callback(item);
                        }
                        else
                        {
                            getTransferItem(flag, callback);
                        }
                    }
                    else
                    {
                        callback(null);
                    }
                }
                else
                {
                    TransferItem obj = remoteQueue.Count > 0 ? remoteQueue.Dequeue() : null;
                    if (null != obj)
                    {
                        if (checkTransferItem(obj))
                        {
                            item = obj;
                            remoteList.Add(item);
                            callback(item);
                        }
                        else
                        {
                            getTransferItem(flag, callback);
                        }
                    }
                    else
                    {
                        callback(null);
                    }
                }
            });
        }

19 View Source File : MicroVM.CPU.cs
License : MIT License
Project Creator : a-downing

public bool Cycle(out Status status, int numCycles = 1) {
            savedStatus = Status.UNDEFINED;

            for(int i = 0; i < numCycles; i++) {
                if(savedStatus != Status.UNDEFINED) {
                    status = savedStatus;
                    return false;
                }

                if((flags & (uint)Flag.INTERRUPTS_ENABLED) != 0 && pendingInterrupts.Count != 0) {
                    uint addr = pendingInterrupts.Dequeue();

                    replacedignMemory(registers[(int)Register.SP], pc);
                    registers[(int)Register.SP] += 4;
                    pc = addr;

                    if(savedStatus != Status.UNDEFINED) {
                        status = savedStatus;
                        return false;
                    }
                }

                if(pc >= instructions.Length) {
                    status = Status.OUT_OF_INSTRUCTIONS;
                    return false;
                }

                uint inst = instructions[pc++];
                Opcode opcode = (Opcode)((inst & (uint)Instruction.OPCODE_MASK) >> (int)Instruction.OPCODE_SHIFT);
                Cond cond = (Cond)((inst & (int)Instruction.COND_MASK) >> (int)Instruction.COND_SHIFT);
                uint op1Flag = inst & (uint)Instruction.OP1_FLAG_MASK;
                uint op2Flag = inst & (uint)Instruction.OP2_FLAG_MASK;
                uint op3Flag = inst & (uint)Instruction.OP3_FLAG_MASK;
                uint immediate = 0;
                bool nextIsImmediate = false;

                /*Program.Print("");
                Program.PrintVar(nameof(pc), pc);
                Program.Print($"instruction: {opcode}.{cond}");
                Program.Print($"instruction bits: {Convert.ToString(inst, 2).PadLeft(32, '0')}");
                Program.Print($"flags: {Convert.ToString(flags & (uint)Flag.EQUAL, 2).PadLeft(32, '0')}");*/

                if(op1Flag == 0) {
                    immediate = inst & (uint)Instruction.IMM1_MASK;

                    if(immediate == (uint)Instruction.IMM1_MASK) {
                        nextIsImmediate = true;
                    }
                } else if(op2Flag == 0) {
                    immediate = inst & (uint)Instruction.IMM2_MASK;

                    if(immediate == (uint)Instruction.IMM2_MASK) {
                        nextIsImmediate = true;
                    }
                } else if(op3Flag == 0) {
                    immediate = inst & (uint)Instruction.IMM3_MASK;

                    if(immediate == (uint)Instruction.IMM3_MASK) {
                        nextIsImmediate = true;
                    }
                }

                if(nextIsImmediate) {
                    if(pc >= instructions.Length) {
                        status = Status.OUT_OF_INSTRUCTIONS;
                        return false;
                    }

                    immediate = instructions[pc++];
                }

                switch(cond) {
                    case Cond.EQ:
                        if((flags & (uint)Flag.EQUAL) != 0) {
                            break;
                        }

                        continue;
                    case Cond.NE:
                        if((flags & (uint)Flag.EQUAL) == 0) {
                            break;
                        }

                        continue;
                    case Cond.GT:
                        if((flags & (uint)Flag.GREATER_THAN) != 0) {
                            break;
                        }

                        continue;
                    case Cond.LT:
                        if((flags & (uint)Flag.LESS_THAN) != 0) {
                            break;
                        }

                        continue;
                    case Cond.GE:
                        if((flags & (uint)(Flag.GREATER_THAN | Flag.EQUAL)) != 0) {
                            break;
                        }

                        continue;
                    case Cond.LE:
                        if((flags & (uint)(Flag.LESS_THAN | Flag.EQUAL)) != 0) {
                            break;
                        }

                        continue;
                }

                bool handledHere = true;

                // zero arg instructions
                switch(opcode) {
                    case Opcode.NOP:
                        break;
                    case Opcode.RET:
                        registers[(int)Register.SP] -= 4;
                        pc = ReadMemory(registers[(int)Register.SP]).Uint;
                        break;
                    case Opcode.CLI:
                        flags &= ~(uint)Flag.INTERRUPTS_ENABLED;
                        break;
                    case Opcode.SEI:
                        flags |= (uint)Flag.INTERRUPTS_ENABLED;
                        break;
                    default:
                        handledHere = false;
                        break;
                }

                if(handledHere) {
                    continue;
                }

                uint op1 = (inst & (uint)Instruction.OP1_MASK) >> (int)Instruction.OP1_SHIFT;
                uint arg1 = (op1Flag != 0) ? registers[op1] : immediate;
                // just testing this, if it's not slower, arg1 will just be a Value32
                Value32 arg1v = new Value32 { Uint = arg1 };
                handledHere = true;

                /*Program.PrintVar(nameof(op1), op1);
                Program.PrintVar(nameof(op1Flag), op1Flag);
                Program.PrintVar(nameof(immediate), immediate);
                Program.PrintVar(nameof(arg1), arg1);*/

                // one arg instructions
                switch(opcode) {
                    case Opcode.JMP:
                        pc = arg1;
                        break;
                    case Opcode.CALL:
                        replacedignMemory(registers[(int)Register.SP], pc);
                        registers[(int)Register.SP] += 4;
                        pc = arg1;
                        break;
                    case Opcode.PUSH:
                        replacedignMemory(registers[(int)Register.SP], arg1);
                        registers[(int)Register.SP] += 4;
                        break;
                    case Opcode.POP:
                        registers[(int)Register.SP] -= 4;
                        registers[op1] = ReadMemory(registers[(int)Register.SP]).Uint;
                        break;
                    case Opcode.ITOF:
                        var itof = new Value32 { Uint = registers[op1] };
                        itof.Float = (float)itof.Int;
                        registers[op1] = itof.Uint;
                        break;
                    case Opcode.FTOI:
                        var ftoi = new Value32 { Uint = registers[op1] };
                        ftoi.Int = (int)ftoi.Float;
                        registers[op1] = ftoi.Uint;
                        break;
                    case Opcode.RNGI:
                        registers[op1] = (uint)random.Next();
                        break;
                    case Opcode.RNGF:
                        var rngf = new Value32 { Float = (float)random.NextDouble() };
                        registers[op1] = rngf.Uint;
                        break;
                    default:
                        handledHere = false;
                        break;
                }

                if(handledHere) {
                    continue;
                }

                uint op2 = (inst & (uint)Instruction.OP2_MASK) >> (int)Instruction.OP2_SHIFT;
                uint arg2 = (op2Flag != 0) ? registers[op2] : immediate;
                Value32 arg2v = new Value32 { Uint = arg2 };
                handledHere = true;

                /*Program.PrintVar(nameof(op2), op2);
                Program.PrintVar(nameof(op2Flag), op2Flag);
                Program.PrintVar(nameof(immediate), immediate);
                Program.PrintVar(nameof(arg2), arg2);*/

                // two arg instructions
                switch(opcode) {
                    case Opcode.MOV:
                        registers[op1] = arg2;
                        break;
                    case Opcode.CMPI:
                        flags = ((int)arg1 == (int)arg2) ? flags | (uint)Flag.EQUAL : flags & ~(uint)Flag.EQUAL;
                        flags = ((int)arg1 > (int)arg2) ? flags | (uint)Flag.GREATER_THAN : flags & ~(uint)Flag.GREATER_THAN;
                        flags = ((int)arg1 < (int)arg2) ? flags | (uint)Flag.LESS_THAN : flags & ~(uint)Flag.LESS_THAN;
                        break;
                    case Opcode.CMPU:
                        flags = (arg1 == arg2) ? flags | (uint)Flag.EQUAL : flags & ~(uint)Flag.EQUAL;
                        flags = (arg1 > arg2) ? flags | (uint)Flag.GREATER_THAN : flags & ~(uint)Flag.GREATER_THAN;
                        flags = (arg1 < arg2) ? flags | (uint)Flag.LESS_THAN : flags & ~(uint)Flag.LESS_THAN;
                        break;
                    case Opcode.CMPF:
                        flags = (arg1v.Float == arg2v.Float) ? flags | (uint)Flag.EQUAL : flags & ~(uint)Flag.EQUAL;
                        flags = (arg1v.Float > arg2v.Float) ? flags | (uint)Flag.GREATER_THAN : flags & ~(uint)Flag.GREATER_THAN;
                        flags = (arg1v.Float < arg2v.Float) ? flags | (uint)Flag.LESS_THAN : flags & ~(uint)Flag.LESS_THAN;
                        break;
                    default:
                        handledHere = false;
                        break;
                }

                if(handledHere) {
                    continue;
                }

                uint op3 = (inst & (uint)Instruction.OP3_MASK) >> (int)Instruction.OP3_SHIFT; 
                uint arg3 = (op3Flag != 0) ? registers[op3] : immediate;
                Value32 arg3v = new Value32 { Uint = arg3 };
                handledHere = true;

                /*Program.PrintVar(nameof(op3), op3);
                Program.PrintVar(nameof(op3Flag), op3Flag);
                Program.PrintVar(nameof(immediate), immediate);
                Program.PrintVar(nameof(arg3), arg3);*/

                // three arg instructions
                switch(opcode) {
                    case Opcode.LDR:
                        registers[op1] = ReadMemory((uint)(arg2 + arg3v.Int)).Uint;
                        break;
                    case Opcode.STR:
                        replacedignMemory((uint)(arg2 + arg3v.Int), arg1);
                        break;
                    case Opcode.LDRB:
                        registers[op1] = ReadMemoryByte((uint)(arg2 + arg3v.Int));
                        break;
                    case Opcode.STRB:
                        replacedignMemoryByte((uint)(arg2 + arg3v.Int), (byte)arg1);
                        break;
                    case Opcode.SHRS:
                        registers[op1] = (uint)((int)arg2 >> (int)arg3);
                        break;
                    case Opcode.SHRU:
                        registers[op1] = arg2 >> (int)arg3;
                        break;
                    case Opcode.SHL:
                        registers[op1] = arg2 << (int)arg3;
                        break;
                    case Opcode.AND:
                        registers[op1] = arg2 & arg3;
                        break;
                    case Opcode.OR:
                        registers[op1] = arg2 | arg3;
                        break;
                    case Opcode.XOR:
                        registers[op1] = arg2 ^ arg3;
                        break;
                    case Opcode.NOT:
                        registers[op1] = ~arg2;
                        break;
                    case Opcode.ADD:
                        registers[op1] = arg2 + arg3;
                        break;
                    case Opcode.SUB:
                        registers[op1] = arg2 - arg3;
                        break;
                    case Opcode.MUL:
                        registers[op1] = arg2 * arg3;
                        break;
                    case Opcode.DIV:
                        if(arg2 == 0) {
                            status = Status.DIVISION_BY_ZERO;
                            return false;
                        }

                        registers[op1] = arg2 / arg3;
                        break;
                    case Opcode.MOD:
                        if(arg2 == 0) {
                            status = Status.DIVISION_BY_ZERO;
                            return false;
                        }

                        registers[op1] = arg2 % arg3;
                        break;
                    case Opcode.ADDF:
                        registers[op1] = new Value32 { Float = arg2v.Float + arg3v.Float }.Uint;
                        break;
                    case Opcode.SUBF:
                        registers[op1] = new Value32 { Float = arg2v.Float - arg3v.Float }.Uint;
                        break;
                    case Opcode.MULF:
                        registers[op1] = new Value32 { Float = arg2v.Float * arg3v.Float }.Uint;
                        break;
                    case Opcode.DIVF:
                        if(arg2v.Float == 0) {
                            status = Status.DIVISION_BY_ZERO;
                            return false;
                        }

                        registers[op1] = new Value32 { Float = arg2v.Float / arg3v.Float }.Uint;
                        break;
                    case Opcode.MODF:
                        if(arg2v.Float == 0) {
                            status = Status.DIVISION_BY_ZERO;
                            return false;
                        }

                        registers[op1] = new Value32 { Float = arg2v.Float % arg3v.Float }.Uint;
                        break;
                    default:
                        handledHere = false;
                        break;
                }

                if(handledHere) {
                    continue;
                }

                status = Status.MISSING_INSTRUCTION;
                return false;
            }

            if(savedStatus != Status.UNDEFINED) {
                status = savedStatus;
                return false;
            } else {
                status = Status.SUCCESS;
                return true;
            }
        }

19 View Source File : Event.cs
License : MIT License
Project Creator : 7Bytes-Studio

private static void DeSyncQueue()
        {
            while (0< s_QueueEventTopic.Count)
            {
                s_QueueEventTopic.Dequeue();
            }
        }

19 View Source File : ObjectBaseEventSystem.cs
License : MIT License
Project Creator : 404Lcc

private void Start()
        {
            while (start.Count > 0)
            {
                long id = start.Dequeue();
                if (aObjectBases.ContainsKey(id))
                {
                    AObjectBase aObjectBase = (AObjectBase)aObjectBases[id];
                    aObjectBase.Start();
                }
            }
        }

19 View Source File : VersionControlLogReader.cs
License : MIT License
Project Creator : aabiryukov

public override string ReadLine()
        {
            const int ChangesetTimeMilliseconds = 3000;

            if (m_vcs == null)
                Connect();

            if (m_latestChangesetId == 0)
            {
                // First run. Searching latest changeset
                var latestChangeset = GetLatestChangeset();
                if (latestChangeset == null)
                    return null; // No any chanesets found!

                foreach (var line in m_changesetConverter.GetLogLines(latestChangeset))
                {
                    m_latestChanges.Enqueue(line);
                }

                // How mutch a wait before get next line
                m_waitMilliseconds = m_latestChanges.Count > 0 ? ChangesetTimeMilliseconds / m_latestChanges.Count : 0;

                m_latestChangesetId = latestChangeset.ChangesetId;
            }
            else
            {
               if (m_latestChanges.Count == 0)
               {
                   // Getting new changes after latest previous changeset Id
                   var foundChanges = FindLatestChanges(m_latestChangesetId);
                   if (foundChanges != null)
                   {
                       foreach (var changeset in foundChanges)
                       {
                           foreach (var line in m_changesetConverter.GetLogLines(changeset))
                           {
                               m_latestChanges.Enqueue(line);
                           }

                           m_latestChangesetId = changeset.ChangesetId;
                       }
                   }

                   // How mutch a wait before get next line
                   m_waitMilliseconds = m_latestChanges.Count > 0 ? ChangesetTimeMilliseconds / m_latestChanges.Count : 0;
               }
            }

            if (m_latestChanges.Count == 0)
                return null;

            // Simulate changes time to avoid super fast
            var sleepTime = m_waitMilliseconds - (Environment.TickCount - m_lastReadLineTicks);
            if (sleepTime > 0 && sleepTime <= m_waitMilliseconds)
            {
                System.Diagnostics.Debug.WriteLine("WAIT: " + sleepTime);
                System.Threading.Thread.Sleep(sleepTime);
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("WAIT: none");
            }
            m_lastReadLineTicks = Environment.TickCount;

            return m_latestChanges.Dequeue();
        }

19 View Source File : RedisArray.cs
License : MIT License
Project Creator : 2881099

public override object[] Parse(RedisReader reader)
        {
            if (_parsers.Count == 0)
                return reader.ReadMultiBulk(bulkreplacedtring: true);

            reader.ExpectType(RedisMessage.MultiBulk);
            long count = reader.ReadInt(false);
            if (count != _parsers.Count)
                throw new RedisProtocolException(String.Format("Expecting {0} array items; got {1}", _parsers.Count, count));

            object[] results = new object[_parsers.Count];
            for (int i = 0; i < results.Length; i++)
                results[i] = _parsers.Dequeue()(reader);
            return results;
        }

19 View Source File : DelayedEvents.cs
License : MIT License
Project Creator : Abdesol

public void RaiseEvents()
		{
			while (eventCalls.Count > 0)
				eventCalls.Dequeue().Call();
		}

19 View Source File : ETTask.cs
License : MIT License
Project Creator : 404Lcc

public static ETTask Create(bool fromPool)
        {
            if (!fromPool)
            {
                return new ETTask(fromPool);
            }
            else
            {
                if (_etTaskQueue.Count == 0)
                {
                    return new ETTask(true);
                }
                return _etTaskQueue.Dequeue();
            }
        }

19 View Source File : AsyncCoroutineRunner.cs
License : Apache License 2.0
Project Creator : abist-co-ltd

private void Update()
        {
            Debug.replacedert(Instance != null);

            int actionCount;

            lock (Actions)
            {
                actionCount = Actions.Count;
            }

            for (int i = 0; i < actionCount; i++)
            {
                Action next;

                lock (Actions)
                {
                    next = Actions.Dequeue();
                }

                next();
            }
        }

19 View Source File : DialogueManagerController.cs
License : MIT License
Project Creator : 0xbustos

public bool DisplayNextSentence()
        {
            foreach (LetterComponent letter in this.letters)
            {
                GameObject.Destroy( letter.gameObject );
            }

            this.currentSpeed = this.Model.WaitTime;
            this.currentEffect = null;
            this.effects.Clear();
            this.speeds.Clear();
            this.letters.Clear();
            this.currentX = 0;
            this.currentY = 0;

            if (sentences.Count == 0)
            {
                EndDialogue();
                return false;
            }

            this.Model.ImageText.sprite = sprites.Dequeue();
            this.sentence = sentences.Dequeue();
            this.audioQueue = voices.Dequeue();
            this.Model.WaitTime = 0f;
            string onlyWords = string.Empty;

            for (int i = 0; i < this.sentence.Length; i++)
            {
                if (this.sentence[i] == '[')
                {
                    i = this.changeSpeed( i );
                }
                else if (this.sentence[i] == '<')
                {
                    i = this.changeEffect( i );
                }
                else
                {
                    this.effects.Add( this.currentEffect );
                    if (this.sentence[i] != ' ')
                    {
                        this.speeds.Add( ( float )this.currentSpeed );
                    }
                    onlyWords += this.sentence[i];
                }
            }

            string[] words = onlyWords.Split( ' ' );
            int letterSpacing = ( int )( this.fontSize * 0.5 );
            int currentIndexEffects = 0;
            int currentIndexSpeeds = 0;
            foreach (string word in words)
            {
                GameObject wordObject = new GameObject( word, typeof( RectTransform ) );
                wordObject.transform.SetParent( this.Model.DialogueStartPoint );
                int wordSize = word.Length * letterSpacing;
                if (this.currentX + wordSize > this.boxSize)
                {
                    this.currentX = 0;
                    this.currentY -= ( int )( this.fontSize * 0.9 );
                }
                wordObject.GetComponent<RectTransform>().localPosition = new Vector3( currentX, currentY, 0 );

                for (int i = 0; i < word.Length; i++)
                {
                    GameObject letterObject = new GameObject( word[i].ToString() );
                    letterObject.transform.SetParent( wordObject.transform );
                    Text myText = letterObject.AddComponent<Text>();
                    myText.text = word[i].ToString();
                    myText.alignment = TextAnchor.LowerCenter;
                    myText.fontSize = this.fontSize;
                    myText.font = this.Model.Font;
                    myText.material = this.Model.Material;
                    myText.GetComponent<RectTransform>().localPosition = new Vector3( i * letterSpacing, 0, 0 );
                    myText.color = new Color( 0.0f, 0.0f, 0.0f, 0.0f );
                    RectTransform rt = letterObject.GetComponentInParent<RectTransform>();
                    rt.sizeDelta = new Vector2( this.fontSize, this.fontSize );
                    rt.pivot = new Vector2( 0, 1 );

                    LetterComponent letterComponent = letterObject.AddComponent<LetterComponent>();
                    
                    Letter newLetter = new Letter
                    {
                        Character = word[i],
                        Speed = this.speeds[currentIndexSpeeds],
                        isActive = false
                    };
                    if (this.effects[currentIndexEffects] != null)
                    {
                        newLetter.Effect = this.effects[currentIndexEffects].Build( letterObject );
                    }
                    letterComponent.Model = newLetter;
                    this.letters.Add( letterComponent );
                    currentIndexEffects++;
                    currentIndexSpeeds++;
                }
                currentX += wordSize + letterSpacing;
                currentIndexEffects++;
            }
            return true;
        }

19 View Source File : OvrAvatarRemoteDriver.cs
License : MIT License
Project Creator : absurd-joy

private void UpdateFromUnityPacket(IntPtr sdkAvatar)
    {
        // If we're not currently streaming, check to see if we've buffered enough
        if (!isStreaming && packetQueue.Count > MinPacketQueue)
        {
            currentPacket = packetQueue.Dequeue();
            isStreaming = true;
        }

        // If we are streaming, update our pose
        if (isStreaming)
        {
            CurrentPacketTime += Time.deltaTime;

            // If we've elapsed past our current packet, advance
            while (CurrentPacketTime > currentPacket.Duration)
            {

                // If we're out of packets, stop streaming and
                // lock to the final frame
                if (packetQueue.Count == 0)
                {
                    CurrentPose = currentPacket.FinalFrame;
                    CurrentPacketTime = 0.0f;
                    currentPacket = null;
                    isStreaming = false;
                    return;
                }

                while (packetQueue.Count > MaxPacketQueue)
                {
                    packetQueue.Dequeue();
                }

                // Otherwise, dequeue the next packet
                CurrentPacketTime -= currentPacket.Duration;
                currentPacket = packetQueue.Dequeue();
            }

            // Compute the pose based on our current time offset in the packet
            CurrentPose = currentPacket.GetPoseFrame(CurrentPacketTime);

            UpdateTransformsFromPose(sdkAvatar);
        }
    }

19 View Source File : ActionQueue.cs
License : MIT License
Project Creator : 7Bytes-Studio

public Action Dequeue()
        {
           return s_Queue.Dequeue();
        }

19 View Source File : ActionQueue.cs
License : MIT License
Project Creator : 7Bytes-Studio

public void DequeueAll()
        {
            while (0 < s_Queue.Count)
            {
                s_Queue.Dequeue().Invoke();
            }
        }

19 View Source File : ExifParser.cs
License : MIT License
Project Creator : 0xC0000054

private static List<ParserIFDEntry> ParseDirectories(EndianBinaryReader reader, uint firstIFDOffset)
        {
            List<ParserIFDEntry> items = new List<ParserIFDEntry>();

            bool foundExif = false;
            bool foundGps = false;
            bool foundInterop = false;

            Queue<MetadataOffset> ifdOffsets = new Queue<MetadataOffset>();
            ifdOffsets.Enqueue(new MetadataOffset(MetadataSection.Image, firstIFDOffset));

            while (ifdOffsets.Count > 0)
            {
                MetadataOffset metadataOffset = ifdOffsets.Dequeue();

                MetadataSection section = metadataOffset.Section;
                uint offset = metadataOffset.Offset;

                if (offset >= reader.Length)
                {
                    continue;
                }

                reader.Position = offset;

                ushort count = reader.ReadUInt16();
                if (count == 0)
                {
                    continue;
                }

                items.Capacity += count;

                for (int i = 0; i < count; i++)
                {
                    ParserIFDEntry entry = new ParserIFDEntry(reader, section);

                    switch (entry.Tag)
                    {
                        case TiffConstants.Tags.ExifIFD:
                            if (!foundExif)
                            {
                                foundExif = true;
                                ifdOffsets.Enqueue(new MetadataOffset(MetadataSection.Exif, entry.Offset));
                            }
                            break;
                        case TiffConstants.Tags.GpsIFD:
                            if (!foundGps)
                            {
                                foundGps = true;
                                ifdOffsets.Enqueue(new MetadataOffset(MetadataSection.Gps, entry.Offset));
                            }
                            break;
                        case TiffConstants.Tags.InteropIFD:
                            if (!foundInterop)
                            {
                                foundInterop = true;
                                ifdOffsets.Enqueue(new MetadataOffset(MetadataSection.Interop, entry.Offset));
                            }
                            break;
                        case TiffConstants.Tags.StripOffsets:
                        case TiffConstants.Tags.RowsPerStrip:
                        case TiffConstants.Tags.StripByteCounts:
                        case TiffConstants.Tags.SubIFDs:
                        case TiffConstants.Tags.ThumbnailOffset:
                        case TiffConstants.Tags.ThumbnailLength:
                            // Skip the thumbnail and/or preview images.
                            // The StripOffsets and StripByteCounts tags are used to store a preview image in some formats.
                            // The SubIFDs tag is used to store thumbnails in TIFF and for storing other data in some camera formats.
                            //
                            // Note that some cameras will also store a thumbnail as part of their private data in the EXIF MakerNote tag.
                            // The EXIF MakerNote tag is treated as an opaque blob, so those thumbnails will be preserved.
                            break;
                        default:
                            items.Add(entry);
                            break;
                    }

                    System.Diagnostics.Debug.WriteLine(entry.ToString());
                }
            }

            return items;
        }

19 View Source File : ObjectQueue{T}.cs
License : MIT License
Project Creator : 7Bytes-Studio

public T Spawn()
        {
            lock (s_Lock)
            {
                if (0 < m_ObjectQueue.Count)
                    return m_ObjectQueue.Dequeue();
                else
                    return m_ObjectQueueFactoryCallback.Invoke();
            }
        }

19 View Source File : CommandPacket.cs
License : MIT License
Project Creator : 2881099

internal void OnDataTrigger(RedisResult rt)
        {
            if (_ondata == null) return;
            while (_ondata.Any())
                _ondata.Dequeue()(rt);
        }

19 View Source File : Log.LogFile.partial.cs
License : MIT License
Project Creator : 7Bytes-Studio

private static void WritelogQueueToLogFile()
        {
            var logMessage = string.Empty;
            while (0<s_QueueLogToFileString.Count)
            {
                logMessage += s_QueueLogToFileString.Dequeue()+"\r\n";
            }

            using (FileStream fileStream = new FileStream(s_LogFilePath, FileMode.Append))
            {
                byte[] buffer = Encoding.UTF8.GetBytes(logMessage);
                fileStream.BeginWrite(buffer, 0, buffer.Length, a => {

                    var fs = a.AsyncState as FileStream;
                    fs.EndWrite(a);

                }, fileStream);
            }

        }

19 View Source File : Job.LifeCircle.partial.cs
License : MIT License
Project Creator : 7Bytes-Studio

private static void DeSyncStateQueue()
        {
            while (0<s_QueueJobStateSyncData.Count)
            {
                var jobStateSync =  s_QueueJobStateSyncData.Dequeue();
                if (null!= jobStateSync.DoneSyncCallback)
                {
                    jobStateSync.DoneSyncCallback.Invoke(jobStateSync.JobState);
                }
            }
        }

19 View Source File : ObjectBaseEventSystem.cs
License : MIT License
Project Creator : 404Lcc

private void LateUpdate()
        {
            while (lateUpdate.Count > 0)
            {
                long id = lateUpdate.Dequeue();
                if (aObjectBases.ContainsKey(id))
                {
                    AObjectBase aObjectBase = (AObjectBase)aObjectBases[id];
                    aObjectBase.LateUpdate();
                    lateUpdateCopy.Enqueue(id);
                }
            }
            ObjectUtil.Swap(ref lateUpdate, ref lateUpdateCopy);
        }

19 View Source File : ConcurrentQueue.cs
License : MIT License
Project Creator : a11s

public bool TryDequeue(out T item)
        {
            lock (innerQueue)
            {
                if (innerQueue.Count > 0)
                {
                    item = innerQueue.Dequeue();
                    return true;
                }
                else
                {
                    item = default(T);
                    return false;
                }
            }
        }

19 View Source File : BssMapObjMarshal.cs
License : MIT License
Project Creator : 1996v

private static unsafe void WriteValues(ref BssomWriter writer, IBssomFormatter<TValue> formatter, long basePostion, ref BssomSerializeContext context, Queue<KeyValuePair<int, TValue>> valueMapOffsets, ref StackArrayPack<BssMapWriteBackEntry> writeBacks)
        {
            while (valueMapOffsets.Count > 0)
            {
                context.CancellationToken.ThrowIfCancellationRequested();
                KeyValuePair<int, TValue> item = valueMapOffsets.Dequeue();

                writeBacks.Add(new BssMapWriteBackEntry() { MapOffset = item.Key, ValueOffset = (uint)(writer.Position - basePostion) });
                formatter.Serialize(ref writer, ref context, item.Value);
            }
        }

19 View Source File : PeerBase.cs
License : MIT License
Project Creator : a11s

internal void UpdateInternal()
        {
            while (IncomingData.Count > 0)
            {
                var buf = IncomingData.Dequeue();
                BeforeOperationRequest(buf);

            }

            #region 这里跟UdpServer不一样
            while (Fiber.works.Count > 0)
            {
                var a = Fiber.works.Dequeue();
                a.Invoke();
            }
            #endregion

            while (this.Channel.CanSend && OutgoingData.Count > 0)
            {
                var buf2 = OutgoingData.Dequeue();
#if PRINTPACK
                Console.WriteLine($"realsend:{buf2.Length}:{string.Join(",", buf2)}");
#endif
                //this.Channel.WriteAndFlushAsync(new DotNetty.Transport.Channels.Sockets.DatagramPacket(DotNetty.Buffers.Unpooled.Buffer(buf2.Length).WriteBytes(buf2), Context.RemoteEP));
                this.Channel.Send(buf2, Context.RemoteEP);
            }

            DeriverUpdate();
        }

19 View Source File : ETTask.cs
License : MIT License
Project Creator : 404Lcc

public static ETTask<T> Create(bool fromPool = false)
        {
            if (!fromPool)
            {
                return new ETTask<T>(fromPool);
            }
            else
            {
                if (_etTaskQueue.Count == 0)
                {
                    return new ETTask<T>(true);
                }
                return _etTaskQueue.Dequeue();
            }
        }

19 View Source File : ModBaseData.cs
License : Apache License 2.0
Project Creator : AantCoder

public override void Update()
        {
            if (MainThreadNum == int.MinValue)
            {
                MainThreadNum = Thread.CurrentThread.ManagedThreadId;
            }

            lock (MainThreadLock)
            {
                while (MainThread.Count > 0)
                {
                    var qa = MainThread.Dequeue();
                    try
                    {
                        qa.Act();
                    }
                    catch(Exception ext)
                    {
                        Loger.Log("Client RunMainThread Exception " + ext.ToString());
                    }
                    ActionNumReady = qa.Num;
                }
            }
        }

19 View Source File : patch_Program.cs
License : MIT License
Project Creator : 0x0ade

[STAThread]
        public static void Main(string[] args) {
            bool nothreading = true;
            bool nomods = true;

            Queue<string> argq = new Queue<string>(args);
            while (argq.Count > 0) {
                string arg = argq.Dequeue();
                if (arg == "-debug")
                    Debugger.Launch();
                else if (arg == "-yesthreading")
                    nothreading = false;
                else if (arg == "-yesmods")
                    nomods = false;
            }

            List<string> argl = new List<string>(args);
            argl.Add("<");

            if (nothreading)
                argl.Add("-nothreading");

            if (nomods)
                argl.Add("-nomods");

            argl.Add(">");

            args = argl.ToArray();

            // Parse arguments again...
            argq = new Queue<string>(args);
            while (argq.Count > 0) {
                string arg = argq.Dequeue();
                if (arg == "-nomods")
                    // MonoMain.moddingEnabled = false skips ManagedContent.InitializeMods.
                    // InitializeMods calls ModLoader.LoadMods.
                    // LoadMods sets ModLoader.modHash.
                    // -nomods thus leaves ModLoader.modHash == null, which causes issues.
                    patch_ModLoader.DefaultModHash();
            }

            orig_Main(args);
        }

19 View Source File : Program.cs
License : MIT License
Project Creator : abanu-org

private static void WriteThread()
        {
            try
            {
                while (true)
                {
                    WriteWaiter.WaitOne();

                    while (true)
                    {

                        byte[] data;
                        lock (WriteQueue)
                        {
                            if (WriteQueue.Count == 0)
                                break;
                            data = WriteQueue.Dequeue();
                        }

                        stream.Write(data, 0, data.Length);
                    }
                }
            }
            catch (Exception)
            {
                if (!IsConnecting)
                    Restart();
            }
        }

19 View Source File : ObjectBaseEventSystem.cs
License : MIT License
Project Creator : 404Lcc

private void FixedUpdate()
        {
            while (fixedUpdate.Count > 0)
            {
                long id = fixedUpdate.Dequeue();
                if (aObjectBases.ContainsKey(id))
                {
                    AObjectBase aObjectBase = (AObjectBase)aObjectBases[id];
                    aObjectBase.FixedUpdate();
                    fixedUpdateCopy.Enqueue(id);
                }
            }
            ObjectUtil.Swap(ref fixedUpdate, ref fixedUpdateCopy);
        }

19 View Source File : TransformExtensions.cs
License : Apache License 2.0
Project Creator : abist-co-ltd

private static IEnumerable<Transform> EnumerateHierarchyCore(this Transform root, ICollection<Transform> ignore)
        {
            var transformQueue = new Queue<Transform>();
            transformQueue.Enqueue(root);

            while (transformQueue.Count > 0)
            {
                var parentTransform = transformQueue.Dequeue();

                if (!parentTransform || ignore.Contains(parentTransform)) { continue; }

                for (var i = 0; i < parentTransform.childCount; i++)
                {
                    transformQueue.Enqueue(parentTransform.GetChild(i));
                }

                yield return parentTransform;
            }
        }

19 View Source File : SftpLinuxForm.cs
License : Apache License 2.0
Project Creator : 214175590

private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (COPY_QUEUE.Count > 0)
            {
                string[] items = null;
                string path1, path2;
                for (int i = 0, k = COPY_QUEUE.Count; i < k; i++ )
                {
                    items = COPY_QUEUE.Dequeue();
                    path1 = items[0] + items[1];
                    path2 = getCurrDir();
                    SendShell(string.Format("cp {0} {1}", path1, path2));
                }
                pasteToolStripMenuItem.Enabled = false;

                ThreadPool.QueueUserWorkItem((a) =>
                {
                    Thread.Sleep(500);
                    RefreshFiles();
                });
            }
        }

19 View Source File : GenericXRSDKSpatialMeshObserver.cs
License : Apache License 2.0
Project Creator : abist-co-ltd

private void UpdateObserver()
        {
            if (SpatialAwarenessSystem == null || XRSDKSubsystemHelpers.MeshSubsystem == null) { return; }

            using (UpdateObserverPerfMarker.Auto())
            {
                // Only update the observer if it is running.
                if (IsRunning && (outstandingMeshObject == null))
                {
                    // If we have a mesh to work on...
                    if (meshWorkQueue.Count > 0)
                    {
                        // We're using a simple first-in-first-out rule for requesting meshes, but a more sophisticated algorithm could prioritize
                        // the queue based on distance to the user or some other metric.
                        RequestMesh(meshWorkQueue.Dequeue());
                    }
                    // If enough time has preplaceded since the previous observer update...
                    else if (Time.time - lastUpdated >= UpdateInterval)
                    {
                        // Update the observer orientation if user aligned
                        if (ObserverVolumeType == VolumeType.UserAlignedCube)
                        {
                            ObserverRotation = CameraCache.Main.transform.rotation;
                        }

                        // Update the observer location if it is not stationary
                        if (!IsStationaryObserver)
                        {
                            ObserverOrigin = CameraCache.Main.transform.position;
                        }

                        // The application can update the observer volume at any time, make sure we are using the latest.
                        ConfigureObserverVolume();

                        if (XRSDKSubsystemHelpers.MeshSubsystem.TryGetMeshInfos(meshInfos))
                        {
                            UpdateMeshes(meshInfos);
                        }

                        lastUpdated = Time.time;
                    }
                }
            }
        }

19 View Source File : Server.cs
License : MIT License
Project Creator : 5minlab

IEnumerator HandleRequests() {
            while (true) {
                while (mainRequests.Count == 0) {
                    // yield return new WaitForEndOfFrame();
                    yield return null;
                }

                RequestContext context = null;
                lock (mainRequests) {
                    context = mainRequests.Dequeue();
                }

                HandleRequest(context);
            }
        }

19 View Source File : OvrAvatarRemoteDriver.cs
License : MIT License
Project Creator : absurd-joy

private void UpdateFromSDKPacket(IntPtr sdkAvatar)
    {

        if (CurrentSDKPacket == IntPtr.Zero && packetQueue.Count >= MinPacketQueue)
        {
            CurrentSDKPacket = packetQueue.Dequeue().ovrNativePacket;
        }

        if (CurrentSDKPacket != IntPtr.Zero)
        {
            float PacketDuration = CAPI.ovrAvatarPacket_GetDurationSeconds(CurrentSDKPacket);
            CAPI.ovrAvatar_UpdatePoseFromPacket(sdkAvatar, CurrentSDKPacket, Mathf.Min(PacketDuration, CurrentPacketTime));
            CurrentPacketTime += Time.deltaTime;

            if (CurrentPacketTime > PacketDuration)
            {
                CAPI.ovrAvatarPacket_Free(CurrentSDKPacket);
                CurrentSDKPacket = IntPtr.Zero;
                CurrentPacketTime = CurrentPacketTime - PacketDuration;

                //Throw away packets deemed too old.
                while (packetQueue.Count > MaxPacketQueue)
                {
                    packetQueue.Dequeue();
                }
            }
        }
    }

19 View Source File : Ghost.cs
License : MIT License
Project Creator : 0x0ade

public override void Update() {
            lock (UpdateQueue) {
                IsUpdating = true;
                while (UpdateQueue.Count > 0)
                    UpdateQueue.Dequeue()(this);
                IsUpdating = false;
            }

            if (string.IsNullOrEmpty(NameTag.Name) && Active) {
                RemoveSelf();
                return;
            }

            bool holdable = Interactive && GrabCooldown <= 0f && CelesteNetClientModule.Settings.Interactions && IdleTag == null;

            GrabCooldown -= Engine.RawDeltaTime;
            if (GrabCooldown < 0f)
                GrabCooldown = 0f;

            if (!holdable && Holdable.Holder != null) {
                Collidable = false;
                Holdable.Release(Vector2.Zero);
                Collidable = true;
            }

            if (!HoldableAdded && holdable) {
                HoldableAdded = true;
                Add(Holdable);
            } else if (HoldableAdded && !holdable && !Holdable.IsHeld) {
                HoldableAdded = false;
                Remove(Holdable);
            }
            if (CelesteNetClientModule.Settings.PlayerOpacity == 0) {
                Alpha = 0f;
            } else {
                Alpha = 0.875f * ((CelesteNetClientModule.Settings.PlayerOpacity + 2) / 6f);
            }
            DepthOffset = 0;
            Player p = Scene.Tracker.GetEnreplacedy<Player>();
            if (p != null) {
                float dist = (p.Position - Position).LengthSquared();
                if (CelesteNetClientModule.Settings.PlayerOpacity > 2)
                    Alpha = Calc.LerpClamp(Alpha * 0.5f, Alpha, dist / 256f);
                if (dist <= 256f) {
                    Depth = LastDepth + 1;
                    DepthOffset = 1;
                }
            }

            Hair.Color = LastHairColor * Alpha;
            Hair.Alpha = Alpha;
            Sprite.Color = LastSpriteColor * Alpha;

            if (NameTag.Scene != Scene)
                Scene.Add(NameTag);

            Visible = !Dead;

            base.Update();

            if (Scene is not Level level)
                return;

            if (!level.GetUpdateHair() || level.Overlay is PauseUpdateOverlay)
                Hair.AfterUpdate();

            foreach (GhostFollower gf in Followers)
                if (gf.Scene != level)
                    level.Add(gf);

            if (Holding != null && Holding.Scene != level)
                level.Add(Holding);

            // TODO: Get rid of this, sync particles separately!
            if (DashWasB != null && level != null && Speed != Vector2.Zero && level.OnRawInterval(0.02f))
                level.ParticlesFG.Emit(DashWasB.Value ? Player.P_DashB : Player.P_DashA, Center + Calc.Random.Range(Vector2.One * -2f, Vector2.One * 2f), DashDir.Angle());
        }

19 View Source File : Player.cs
License : MIT License
Project Creator : absurd-joy

public GameObject CreateBall()
		{
			if (m_balls.Count >= MAX_BALLS)
			{
				Destroy(m_balls.Dequeue());
			}
			var ball = Instantiate(m_ballPrefab);
			m_balls.Enqueue(ball);

			ball.transform.position = m_ballEjector.transform.position;
			ball.transform.SetParent(m_ballEjector.transform, true);
			ball.GetComponent<Rigidbody>().useGravity = false;
			ball.GetComponent<Rigidbody>().detectCollisions = false;
			ball.GetComponent<DetectBasket>().Player = this;

			return ball;
		}

19 View Source File : ExpressionTree.Linq.cs
License : MIT License
Project Creator : 71

public bool MoveNext()
            {
                if (queue.Count == 0)
                    return false;

                current = queue.Dequeue();
                return true;
            }

19 View Source File : LandLord.cs
License : Apache License 2.0
Project Creator : 2881099

public Dictionary<int, List<int>> DistributePoker(out Queue<int> LeftCard, int userCount)
        {
            if (userCount != 3)
            {
                TraceLogEx.Error("201610212210ll  userCount > 6 || userCount < 2   " + userCount);
                LeftCard = null;
                return null;
            }
            Shuffle();
            if (ALLPoker.Count != mNumALLPoker)
            {
                TraceLogEx.Error("20120824154401 ALLPoker!= " + mNumALLPoker);
                LeftCard = null;
                return null;
            }
            Dictionary<int, List<int>> retDic = new Dictionary<int, List<int>>();

            //  1 号的数组 牌
            List<int> firstArr = new List<int>();
            //  2 号的数组 牌                          
            List<int> secondArr = new List<int>();
            //  3 号的数组 牌                          
            List<int> thirdArr = new List<int>();

            for (int i = 0; i < _NumPerUser; i++)
            {
                firstArr.Add(ALLPoker.Dequeue());
                secondArr.Add(ALLPoker.Dequeue());
                thirdArr.Add(ALLPoker.Dequeue());
            }

            retDic.Add(1, firstArr);
            retDic.Add(2, secondArr);
            retDic.Add(3, thirdArr);

            LeftCard = ALLPoker;
            if (ALLPoker.Count != 3)
            {
                TraceLogEx.Error(" 20120824154501ll 给地主抓的牌ALLPoker!= 3. 分牌都分错了");
            }
            return retDic;
        }

19 View Source File : RequestQueue.cs
License : MIT License
Project Creator : 0ffffffffh

public static ISozlukRequestHandler PickRequest()
        {
            ISozlukRequestHandler req = null;

            mre.WaitOne();

            if (cancelled)
                return null;

            lock(synchObj)
            {
                if (Requests.Count > 0)
                    req = Requests.Dequeue();

                if (Requests.Count == 0)
                {
                    mre.Reset();
                }
            }

            return req;
        }

19 View Source File : CelesteNetClientContext.cs
License : MIT License
Project Creator : 0x0ade

public override void Update(GameTime gameTime) {
            base.Update(gameTime);

            lock (MainThreadQueue)
                while (MainThreadQueue.Count > 0)
                    MainThreadQueue.Dequeue()();

            if (Started && !(Client?.IsAlive ?? true))
                Dispose();
        }

19 View Source File : BssMapObjMarshal.cs
License : MIT License
Project Creator : 1996v

public unsafe int Size(ref BssomSizeContext context)
        {
            IBssomFormatter<TValue> formatter = context.Option.FormatterResolver.GetFormatterWithVerify<TValue>();

            if (ValueCount == 0)
            {
                return BssMapObjMarshal.Empty.Length;
            }

            int len = SizeHeader(out Queue<KeyValuePair<int, TValue>> valueMapOffsets);
            while (valueMapOffsets.Count > 0)
            {
                KeyValuePair<int, TValue> item = valueMapOffsets.Dequeue();
                len += formatter.Size(ref context, item.Value);
            }

            return len;
        }

19 View Source File : ObjectBaseEventSystem.cs
License : MIT License
Project Creator : 404Lcc

private void Update()
        {
            while (update.Count > 0)
            {
                long id = update.Dequeue();
                if (aObjectBases.ContainsKey(id))
                {
                    AObjectBase aObjectBase = (AObjectBase)aObjectBases[id];
                    aObjectBase.Update();
                    updateCopy.Enqueue(id);
                }
            }
            ObjectUtil.Swap(ref update, ref updateCopy);
        }

19 View Source File : Log.cs
License : MIT License
Project Creator : 7Bytes-Studio

internal static void DeSyncQueue()
        {
            while (0<s_SyncLogQueue.Count)
            {
                var syncLog = s_SyncLogQueue.Dequeue();
                s_LogCallback.Invoke(syncLog.LogLevel, syncLog.Message);
            }
        }

See More Examples