<> <> <> <> <<>> DIRECTORY Xl, Process; XlTQPrivate: CEDAR DEFINITIONS ~ BEGIN <<>> <> TQRec: TYPE = MONITORED RECORD [ <<--type which implements Xl.TQRep>> selfProcess: PROCESS, -- process executing queued events selfRunning: BOOL ¬ FALSE, -- process (selfProcess) exists or will come into existence soon selfRunning2: BOOL ¬ FALSE, -- lockProcess: PROCESS, -- process holding lock [defined if lockCount>0 and ~selfProcess] lockCount: CARD ¬ 0, -- number of locks of processes [defined if ~selfProcess]; << -- lock is free if lockCount=0 AND ~this=NIL>> eventCount: CARD ¬ 0, -- number of queued but not yet handled events next: Job ¬ NIL, -- the next event to be handled tail: Job ¬ NIL, -- for fast inclusion at end of tail newEvent: CONDITION, -- running process sleeps before disappearing lockWaiterCond: CONDITION, -- waiting for change in lock state lockWaiterCount: INT ¬ 0, -- number of processes waiting on lockWaiterCond upperLimit: CARD ¬2000, -- if there are more events we start throwing some away this: Job ¬ NIL, -- Job in execution right now free: Job ¬ NIL, -- list of free entries freeCnt: CARD ¬ 0, -- number of entries on free list order: INT ¬ 0, -- lock order seq1, seq2: INT ¬ 0, -- lock order dead: BOOL ¬ FALSE, -- set using debugger; useful to reduce number of hanging resources props: <> REF ¬ NIL, --reserved for property list priority: Process.Priority ¬ Process.priorityForeground, --used after fork only createData: REF ¬ NIL -- useful for debugging ]; Job: TYPE = REF JobRec; JobRec: TYPE = RECORD [event: Xl.Event, proc: Xl.EventProcType, data: REF, next: Job ¬ NIL]; <> DirtyPeekNextIsMouseEvent: PROC [tq: Xl.TQ] RETURNS [BOOL] = TRUSTED INLINE { <<--To work without lock, this must be called running on tq>> next: Job ¬ LOOPHOLE[tq, REF TQRec].next; RETURN [next#NIL AND next.event#NIL AND next.event.type=motionNotify] }; SetTQReadiness: PROC [tq: Xl.TQ, ms: INT]; <<--TQ stays ready to start up fast for ms milliseconds after last job>> SetTQPriority: PROC [tq: Xl.TQ, priority: Process.Priority]; <<--New priority is set only when freshly forked>> RemoveErrorEvents: PROC [tq: Xl.TQ] <<--Removes all leading error events>> <<--Use when interactively required while debugging>> END.