Beispiel #1
0
        // Update is called once per frame
        void Update()
        {
            // Check Concurrent Pool for data
            SingleLinkNode <byte[]> node = null;

            int dataInSize = 0;

            while (dataIn.Pop(out node))
            {
                dataInSize++;

                byte[] data = node.Item;
                getDataDelegate(data);
                //Debug.Log("DataServerUpdate() got data");

                // parse the data byte array into float values
                dataHandler.parseIncomingBTByteArray(data);


                ////profile time spent
                //after = DateTime.Now;
                //duration = after.Subtract(before);
                //before = DateTime.Now;
                //average_last_ten += duration.Milliseconds;
                //average_last_hundred += duration.Milliseconds;
                //count++;
                //big_count++;


                //if (big_count >= 100)
                //{
                //    Debug.Log("average of last hundred " + average_last_hundred / big_count);
                //    big_count = 0;
                //    average_last_hundred = 0;
                //}

                //if (count >= 10)
                //{
                //    Debug.Log("average of last ten " + average_last_ten / count);
                //    count = 0;
                //    average_last_ten = 0;
                //}
            }

            //if(dataInSize > 0)
            //Debug.Log("size of data q " + dataInSize);


            if (Input.GetKeyDown("space"))
            {
                //sendData("space key was pressed");

                //var unixTimestamp = (DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalMilliseconds;
                //Debug.Log("unix time ms " + unixTimestamp);

                Debug.Log("time ms " + Time.time);
            }
        }
Beispiel #2
0
        // Update is called once per frame
        void Update()
        {
            // Check Concurrent Pool for data
            SingleLinkNode <byte[]> node = null;

            if (dataIn.Pop(out node))
            {
                byte[] data = node.Item;
                getDataDelegate(data);
            }
        }
Beispiel #3
0
        void Update(object sender, EventArgs e)
        {
            // Check Concurrent Pool for data
            List <byte[]>           dataList = new List <byte[]>();
            SingleLinkNode <byte[]> node     = null;

            while (BTDataIn.Pop(out node))
            {
                dataList.Add(node.Item);
            }
            if (dataList.Count > 0)
            {
                // Turn the LIFO list into a FIFO list
                dataList.Reverse();
                foreach (byte[] data in dataList)
                {
                    getBTData(data);
                }
            }
        }
    public void Enqueue(T item)
    {
        SingleLinkNode <T> oldTail = null;
        SingleLinkNode <T> oldTailNext;

        SingleLinkNode <T> newNode;

        if (!trash.Pop(out newNode))
        {
            newNode = new SingleLinkNode <T>();
        }
        else
        {
            newNode.Next = null;
        }
        newNode.Item = item;

        bool newNodeWasAdded = false;

        while (!newNodeWasAdded)
        {
            oldTail     = tail;
            oldTailNext = oldTail.Next;

            if (tail == oldTail)
            {
                if (oldTailNext == null)
                {
                    newNodeWasAdded = SyncMethods.CAS <SingleLinkNode <T> >(ref tail.Next, null, newNode);
                }
                else
                {
                    SyncMethods.CAS <SingleLinkNode <T> >(ref tail, oldTail, oldTailNext);
                }
            }
        }
        count++;
        SyncMethods.CAS <SingleLinkNode <T> >(ref tail, oldTail, newNode);
    }