コード例 #1
0
        static void deliverAllMessages(MetaPool pool, MwsrThreadQueue msgQueue, String filePrefix, ref int msgCnt)
        {
            ThreadQueueItem[] messages = new ThreadQueueItem[16];

            while (true)
            {
                int popped = msgQueue.pop_front(messages);
                if (popped == 0)
                {
                    break;
                }
                for (int i = 0; i < popped; ++i)
                {
                    pool.onMessage(messages[i].msg);
                    ++msgCnt;
                    if (filePrefix != null)
                    {
                        SimpleBuffer buffer   = (SimpleBuffer)messages[i].msg;
                        String       fileName = TestCommon.DataPathPrefix + filePrefix + msgCnt + ".json";

                        // uncomment to update file
                        //buffer.writeToFile(fileName);

                        SimpleBuffer expected = SimpleBuffer.readFromFile(fileName);
                        Assert.True(SimpleBuffer.AreEqualIgnoreEol(expected, buffer));
                    }
                }
            }
        }
コード例 #2
0
        // If you have arguments, use this version
        public ThreadQueueItem EnqueueWork(Action task)
        {
            ThreadQueueItem newItem = new ThreadQueueItem(task);

            workQueue.Enqueue(newItem);
            re.Set();
            return(newItem);
        }