Ejemplo n.º 1
0
        // Can be called from another thread
        private void getBTDataFromThread(byte[] data)
        {
            SingleLinkNode <byte[]> node = new SingleLinkNode <byte[]>();

            node.Item = data;
            BTDataIn.Push(node);
        }
        // Can be called from another thread
        private void getBTDataFromThread(string data)
        {
            SingleLinkNode <string> node = new SingleLinkNode <string>();

            node.Item = data;
            BTDataIn.Push(node);
        }
        void clientGetData(string data)
        {
            // In order to get back to the main thread
            // (Unity cannot handle scene modifications on other threads),
            // we put the data in a concurrent pool
            SingleLinkNode <string> node = new SingleLinkNode <string>();

            node.Item = data;
            dataIn.Push(node);
            // Next part of the pipeline is DataHandler.Update()
        }
Ejemplo n.º 4
0
        void getData(byte[] data)
        {
            //Debug.Log("getData() + " + data);


            // In order to get back to the main thread
            // (Unity cannot handle scene modifications on other threads),
            // we put the data in a concurrent pool
            SingleLinkNode <byte[]> node = new SingleLinkNode <byte[]>();

            node.Item = data;
            dataIn.Push(node);
            // Next part of the pipeline is DataServer.Update()
        }
Ejemplo n.º 5
0
    public bool Dequeue(out T item)
    {
        item = default(T);
        SingleLinkNode <T> oldHead = null;

        bool haveAdvancedHead = false;

        while (!haveAdvancedHead)
        {
            oldHead = head;
            SingleLinkNode <T> oldTail     = tail;
            SingleLinkNode <T> oldHeadNext = oldHead.Next;

            if (oldHead == head)
            {
                if (oldHead == oldTail)
                {
                    if (oldHeadNext == null)
                    {
                        return(false);
                    }
                    SyncMethods.CAS <SingleLinkNode <T> >(ref tail, oldTail, oldHeadNext);
                }
                else
                {
                    item             = oldHeadNext.Item;
                    haveAdvancedHead = SyncMethods.CAS <SingleLinkNode <T> >(ref head, oldHead, oldHeadNext);
                    if (haveAdvancedHead)
                    {
                        trash.Push(oldHead);
                    }
                }
            }
        }
        count--;
        return(true);
    }