Charles.Forsyth20081103-062182904cd18 years agoHistory
89 lines · 1.9 KB · Text
RawDownload
.TH TIMERS 2.SH NAMEtimers \- interval timers.SH SYNOPSIS.EXinclude "timers.m";timers := load Timers Timers->PATH; Timer: adt{   timeout: chan of int;   start:   fn(msec: int): ref Timer;   stop:    fn(t: self ref Timer);}; init:     fn(minms: int): int;shutdown: fn();.EE.SH DESCRIPTION.B Timersprovides simple interval timing.Timeouts are notified by a message sent on a channel,allowing them to provide timeouts in.B altstatements..PPThe module must first be initialised by calling.BR init ,which starts a process to manage the interval timers and returns its process ID.Before exit, the caller must shut the timing process down either by calling.BR shutdown ,which stops it synchronously; by using the process ID returned by.B initto kill it;or by killing the process group of the process thatcalled.BR init(since the timing processes remain in that group)..I Minmsgives the minimum granularity of timing requests in milliseconds..TP.BI Timer.start( msec )Returns a.B Timerthat will expire in.I msecmilliseconds,measured with the granularity of either.IR sys-sleep (2)or the granularity set by.BR init ,whichever is greater..TP.IB t .timeoutAn arbitrary integer value is sent on this channel when the timer.I texpires..TP.IB t .stop()The timer.I tis stoppedand removed from the interval timing queue,if it has not already expired..PPEach.B Timervalue times a single interval.When a timer.I texpires, the timing process attempts, at that and each subsequent timing interval, to send on.IB t .timeoutuntil the expiry message is delivered or the timer is stopped..SH EXAMPLEWait for data to be sent on an input channel, but give up if it does not arrive within 600 milliseconds:.IP.EXt := Timer.start(600);alt {data := <-input =>	t.stop();	# process the data<-t.timeout =>	# request timed out}.EE.SH SEE ALSO.IR sys-millisec (2),.IR sys-sleep (2)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t