Example #1
0
    private void KernelMain()
    {
        CompilerIntrinsics.Cli(); // TODO: superfluous
        for (uint i = 0; i < 50 * 80; i++)
        {
            NucleusCalls.VgaTextWrite(i, 0);
        }

        Thread init = new Thread(new InitThread(), true);

        _NewThread(init);

        uint x = 0xe100;
        uint y = 0;

        while (true)
        {
            CompilerIntrinsics.Cli(); // TODO: superfluous
            NucleusCalls.VgaTextWrite(79, x);
            x++;

            // Schedule thread, wait for exception or interrupt
            ScheduleNextThread();

            // CurrentThread received exception, interrupt, or exited voluntarily
            uint   cid = CurrentThread;
            Thread t   = threadTable[cid];

            CompilerIntrinsics.Cli(); // TODO: superfluous
            uint cState = NucleusCalls.GetStackState(cid);
            if (cState == STACK_EMPTY)
            {
                // Thread received an exception.  Kill it.
                t.alive = false;
            }

            CompilerIntrinsics.Cli(); // TODO: superfluous
            if (t.alive)
            {
                // Thread was interrupted.  It's still ready to run.
                NucleusCalls.SendEoi();
                CheckWakeUp();
                CompilerIntrinsics.Cli(); // TODO: superfluous
                NucleusCalls.StartTimer(0);
                readyQueue.Enqueue(t);
            }
            else
            {
                NucleusCalls.VgaTextWrite(78, (uint)(0x5b00 + 0x1100 * (y++) + 48 + cid));
                // Thread is dead.  Dead threads always jump back to stack 0.
                threadTable[cid] = null;
                NucleusCalls.ResetStack(cid);
            }
        }
    }
 /// <summary>
 /// [Game thread] Sends the parameters to the AI thread.
 /// </summary>
 /// <param name="game_time">Current in-game time (in seconds)</param>
 public static void Send(float game_time)
 {
     Instance.CurrentGameTime = game_time;
     lock (ThreadQueue) { ThreadQueue.Enqueue(Instance); }
     ThreadSignal.Set(); // Waking up the Get() function
     Clear();            // Resetting the instance for next update
 }
Example #3
0
        void PacketReceived(int id, Packet p)
        {
            if (Clients.Contains(id) == false)
            {
                return;
            }
            ClientPacketInfo cpi = new ClientPacketInfo(id, p);

            InputQueue.Enqueue(cpi);
        }
Example #4
0
    internal void EnqueueAndYield(ThreadQueue queue)
    {
        uint   cid     = CurrentThread;
        Thread current = threadTable[cid];

        queue.Enqueue(current);
        ScheduleNextThread();

        // We're back.  Somebody yielded to us.
    }
		public void ShouldCallbackOnCommand()
		{
			ThreadCommand.OnExecute += new OnExecuteDelegate(ThreadCommand_OnExecute);
			ThreadQueue<ThreadCommand> threadQueue = new ThreadQueue<ThreadCommand>();

			TestObject test = new TestObject();

			test.TestString = "Hello World";
			threadQueue.Enqueue(test);
			_resetEvent.WaitOne();
			threadQueue.Dispose();
		}
Example #6
0
        public void AddTask(Delegate task, object[] @params)
        {
            lock (addlock)
            {
                ThreadItem item = new ThreadItem(task, @params);

                if (IsFull)
                {
                    _queue.Enqueue(item);
                }
                else
                {
                    StartThread(item);
                }
            }
        }
Example #7
0
        /// <summary>
        /// Add a thread to the ThreadQueue. It will execute the thread immediately if the thread Instance for this class isn't running
        /// </summary>
        /// <param name="thread">Thread to be added to the ThreadQueue</param>
        public static void AddToQueue(Thread thread, ApartmentState threadType = ApartmentState.Unknown, bool join = false)
        {
            if (ThreadQueue == null)
            {
                ThreadQueue = new Queue <Thread>();
            }

            thread.SetApartmentState(threadType);
            ThreadQueue.Enqueue(thread);

            ThreadingEventArgs args = new ThreadingEventArgs();

            args.Thread = thread;
            Instance.ItemAddedToThreadQueue(args);

            if (!IsThreadRunning())
            {
                Instance.ExecuteQueue(join);
            }
        }
Example #8
0
    /// <summary>
    /// Called when text was edited by user
    /// </summary>
    /// <remarks>When pressed enter or text field lost focus</remarks>
    /// <param name="text">recent text</param>
    public void OnTextEndEdit(string text)
    {
        if (text.IsNullOrEmpty())
        {
            return;
        }

        if (_isMultiThreadingOn)
        {
            _threadQueue.Enqueue(PublishMessage, text);
        }
        else
        {
            PublishMessage(text);
        }

        // disable text field to avoid input lock
        _inputField.enabled = false;
        // reset text and reenable async
        StartCoroutine(EnableInputFieldCoroutine());
    }
Example #9
0
 void PacketReceived(Helper.Multiplayer.Packets.Packet p)
 {
     InputQueue.Enqueue(p);
 }
Example #10
0
 public void Send(byte[] data)
 {
     DataToSendQueue.Enqueue(data);
 }
Example #11
0
 public void StartFunction()
 {
     _QA.Enqueue(AT.Start, _Cmp);
 }
Example #12
0
 void client_PacketReceived(Packet packet)
 {
     InputQueue.Enqueue(packet);
 }