private XQueue xqueue;
private XQueue lqueue; // Events inserted from threads other then the main X thread
private PaintQueue paint; // Paint-only queue
+ internal ArrayList timer_list;
private Thread thread;
+ private bool dispatch_idle;
private static readonly int InitialXEventSize = 100;
private static readonly int InitialLXEventSize = 10;
xqueue = new XQueue (InitialXEventSize);
lqueue = new XQueue (InitialLXEventSize);
paint = new PaintQueue(InitialPaintSize);
+ timer_list = new ArrayList ();
this.thread = thread;
+ this.dispatch_idle = true;
}
public int Count {
public void Enqueue (XEvent xevent)
{
+ if (Thread.CurrentThread != thread) {
+ Console.WriteLine ("Hwnd.Queue.Enqueue called from a different thread without locking.");
+ Console.WriteLine (Environment.StackTrace);
+ }
+
xqueue.Enqueue (xevent);
}
public XEvent Dequeue ()
{
+ if (Thread.CurrentThread != thread) {
+ Console.WriteLine ("Hwnd.Queue.Dequeue called from a different thread without locking.");
+ Console.WriteLine (Environment.StackTrace);
+ }
+
if (xqueue.Count == 0) {
lock (lqueue) {
return lqueue.Dequeue ();
return xqueue.Dequeue ();
}
+ public XEvent Peek()
+ {
+ if (Thread.CurrentThread != thread) {
+ Console.WriteLine ("Hwnd.Queue.Peek called from a different thread without locking.");
+ Console.WriteLine (Environment.StackTrace);
+ }
+
+ if (xqueue.Count == 0) {
+ lock (lqueue) {
+ return lqueue.Peek ();
+ }
+ }
+ return xqueue.Peek();
+ }
+
+ public bool DispatchIdle {
+ get {
+ return dispatch_idle;
+ }
+ set {
+ dispatch_idle = value;
+ }
+ }
+
public class PaintQueue {
private ArrayList hwnds;
return res;
}
+ public XEvent Peek() {
+ if (size < 1) {
+ throw new Exception ("Attempt to peek at empty queue");
+ }
+ return xevents[head];
+ }
+
private void Grow ()
{
int newcap = (xevents.Length * 2);