<<>> <> <> <> <> <<>> DIRECTORY Xl USING [Connection, EventRep, MotionNotifyEvent, Window]; <> <> XlRecycleMotionEvents: CEDAR DEFINITIONS ~ BEGIN EventCache: TYPE = RECORD [ m1, m2: REF Xl.EventRep.motionNotify ¬ NIL ]; GetCache: PROC [c: Xl.Connection, w: Xl.Window] RETURNS [cache: REF EventCache]; <<--Returns a cache where MotionNotifyEvent's can be recycled >> <<--This procedure either returns a harmless (and useless) repository if there are multiple recipients of MotionNotifyEvent's. If the window has exactly one recipient of MotionNotifyEvent's (or is the sentinel used in connection-reader), this returns the actual cache used for allocating events of this connection. >> <<--This is unsafe in the sense that we do not know whether later other recipients of MotionNotifyEvent's will be registered and therefore should only be used in applications which know the window. >> UnsafeRecycle: UNSAFE PROC [recipent: REF EventCache, motionNotify: Xl.MotionNotifyEvent] = TRUSTED INLINE { <<--It is this recipients duty to know that it doesn't forward events it will cache >> IF recipent.m1=NIL THEN recipent.m1 ¬ LOOPHOLE[motionNotify] ELSE recipent.m2 ¬ LOOPHOLE[motionNotify] }; END.