7.1. Real Time

7.1.1. Rwait

The site Rwait is a relative timer. It takes as a nonnegative integer argument a number of milliseconds to wait. It waits for approximately that amount of time, and then responds with a signal.

7.1.2. Rtime

The site Rtime is a program clock. When called, it returns the number of milliseconds that have elapsed since the program began executing.

7.1.3. Rclock

The site Rclock creates new clock instances. When called, it returns a new clock, with two members: wait and time. The wait member behaves exactly like Rwait. The time member returns the number of milliseconds that have passed since the clock was created.

7.1.4. Examples

Simple example of using Rwait
{- Print "red", wait for 3 seconds (3000 ms), and then print "green" -}

Println("red") >> Rwait(3000) >> Println("green") >> stop

include "search.inc"

{- Publish the result of a Google search.
   If it takes more than 5 seconds, time out.
  <result< ( Google("impatience") 
           | Rwait(5000) >> "Search timed out.")

7.1.5. Related Links

Related Tutorial Sections