예제 #1
0
        /*
         * Enqueue SRC in the game's command queue.
         */
        public static void game_proxy_enq(Command src)
        {
            Command dst;

            /*
             * Create the queue.  This is done only once during the life time
             * of the program.  For simplicity's sake, the queue is never
             * destroyed.
             */

            if (game_proxy.cmd_queue == null)
            {
                game_proxy.cmd_queue = CLRQueue.CLR_queue_new();
            }

            /*
             * Add a copy of the command to the end of the queue.
             */

            dst = new Command();
            {
                dst.CopyFrom(src);
                CLRQueue.queue_enq(game_proxy.cmd_queue, dst);
            }
        }
예제 #2
0
        public static void queue_enq(CLRQueue q, object data)
        {
            q.tail.data = data;
            q.tail.next = CLRList.list_cons((object)null, null);

            q.tail = q.tail.next;
        }
예제 #3
0
        public static CLRQueue CLR_queue_new()
        {
            CLRQueue lnew;

            lnew      = new CLRQueue();
            lnew.head = lnew.tail = CLRList.list_cons((object)null, null);

            return(lnew);
        }
예제 #4
0
        public static object queue_deq(CLRQueue q)
        {
            object data = null;

            if (queue_empty(q) == 0)
            {
                data   = q.head.data;
                q.head = CLRList.list_rest(q.head);
            }

            return(data);
        }
예제 #5
0
 /*
  * Dequeue and return the head element in the game's command queue.
  * The element must be freed after use.
  */
 public static Command game_proxy_deq()
 {
     return(cmd_queue != null ? (Command)CLRQueue.queue_deq(cmd_queue) : null);
 }
예제 #6
0
 public static int queue_empty(CLRQueue q)
 {
     return(q.head == q.tail ? 1 : 0);
 }
예제 #7
0
 public static void queue_free(CLRQueue q)
 {
     q.head = null;
     q      = null;
 }