! Clock Module

option  "-NoCheck"

include  "moose:mouse.inc"

Recordformat  clockreqfm (record (messagefm) msg,
                          Integer  ms)


ownrecord (mailboxfm)Name  out == nil

Externalroutine  Clock Wait (Integer  milliseconds)
   record (messagefm)Name  rep
   record (semaphorefm) sem
   record (mailboxfm)   in
   record (clockreqfm)  req
   Integer  i
      
   if  out == nil start 
      i = Find Entry ("CLOCK_REQ",poa_logdict)
      Signal  3,0,0,"Failed to find CLOCK_REQ" if  i = 0
      out == record(integer(i))
   Finish 
   
   setup semaphore (sem)
   setup mailbox (in,sem)
   setup message (req,sizeof(req))

   req_ms = realtime + milliseconds
   send message (req,out,in)
   rep == receive message(in)
End