예제 #1
0
    private ProcessEvent WaitEventDequeEvent()
    {
        lock (this)
        {
            if (this.debug)
            {
                MaloWDebug.Log("ERROR: Proc: " + this.ID + " Mutex for WaitEventDequeEvent Failed, multiple procs modifying data.");
            }
            this.debug = true;

            ProcessEvent ev = this.eventQueue.Dequeue();
            this.debug = false;
            return(ev);
        }
    }
예제 #2
0
    public ProcessEvent PeekEvent()
    {
        lock (this)
        {
            if (this.debug)
            {
                MaloWDebug.Log("ERROR: Proc: " + this.ID + " Mutex for PeekEvent Failed, multiple procs modifying data.");
            }
            this.debug = true;

            ProcessEvent ev = null;
            if (this.eventQueue.Count != 0)
            {
                ev = this.eventQueue.Dequeue();
            }

            this.debug = false;
            return(ev);
        }
    }
예제 #3
0
    private bool WaitEventCheckForSleep()
    {
        lock (this)
        {
            if (this.debug)
            {
                MaloWDebug.Log("ERROR: Proc: " + this.ID + " Mutex for WaitEventCheckForSleep Failed, multiple procs modifying data.");
            }
            this.debug = true;
            bool sleep = this.eventQueue.Count == 0;

            if (sleep)
            {
                this.state = WAITING;
            }

            this.debug = false;
            return(sleep);
        }
    }
예제 #4
0
    public void PutEvent(ProcessEvent ev, bool important)
    {
        lock (this)
        {
            bool go = true;
            if (!important)
            {
                if (this.eventQueue.Count > 20)
                {
                    go = false;
                }
            }

            if (go)
            {
                if (this.debug)
                {
                    MaloWDebug.Log("ERROR: Proc: " + this.ID + " Mutex for PutEvent Failed, multiple procs modifying data.");
                }
                this.debug = true;

                int queueSize = this.eventQueue.Count;

                this.eventQueue.Enqueue(ev);

                if (queueSize > this.warningThresholdEventQueue)
                {
                    MaloWDebug.Log("Warning, EventQueue of process " + this.ID + " has " + this.eventQueue.Count + " unread events.");
                    this.warningThresholdEventQueue *= 2;
                }

                if (this.state == WAITING)
                {
                    this.Resume();
                }

                this.debug = false;
            }
        }
    }