TestCommTimer.mesa
Copyright Ó 1991 by Xerox Corporation. All rights reserved.
Demers, August 29, 1988 5:07:23 pm PDT
DIRECTORY
CommTimer
;
TestCommTimer: CEDAR PROGRAM
IMPORTS CommTimer
~ {
Request: TYPE ~ REF RequestRecord;
RequestRecord: TYPE ~ RECORD [
timer: CommTimer.Timer,
event: CommTimer.Event,
occurred: BOOL ¬ FALSE,
occurredGrains: CommTimer.Grains
];
MyEventProc: CommTimer.EventProc -- [clientData: REF] -- ~ {
request: Request ¬ NARROW[clientData];
request.occurred ¬ TRUE;
request.occurredGrains ¬ CommTimer.GrainsSinceCreated[request.timer];
};
IssueRequest: PROC [t: CommTimer.Timer, n: INT, when: CommTimer.Grains]
RETURNS [list: LIST OF Request ¬ NIL] ~ {
THROUGH [1 .. n] DO
request: Request ¬ NEW[RequestRecord];
request.timer ¬ t;
request.event ¬ CommTimer.ScheduleEvent[t, when, MyEventProc, request];
list ¬ CONS[request, list];
ENDLOOP;
};
CancelRequestI: PROC [list: LIST OF Request, i: INT ¬ 0] ~ {
THROUGH [0 .. i) DO list ¬ list.rest ENDLOOP;
CommTimer.CancelEvent[list.first.timer, list.first.event];
};
}.