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); } }
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); } }
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); } }
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; } } }