Re: Timers: absolute vs relative

"David McClain (as dbm at refined-audiometrics dot com)" <[email protected]> Mon, 27 Jul 2026 11:48:39 -0700
Newsgroups gmane.lisp.lispworks.general
Message-ID <[email protected]>
--Apple-Mail=_7638BC4F-6057-4871-B4D6-67F64CFD83D9
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii

All of mine use relative timeouts...


(defun forced-send-after (dt actor &rest msg)
  (when (realp dt)
    (let ((timer (apply #'mpc:make-timer #'send-to-pool actor msg)))
      (mpc:schedule-timer-relative timer (max 0 dt)))
    ))
 =20
(defun send-after (dt actor &rest msg)
  (when (realp dt)
    (on-commit
      (apply #'forced-send-after dt actor msg))
    ))

(defun send-at (time actor &rest msg)
  ;; Assumes time, entered as hh:mm:ss, is in Turns.
  ;; 0 <=3D Turns < 1.0.
  ;; E.g., 12:00 =3D 12:00:00 =3D 1/2
  (let ((dt (- (+ (round (* time 86400.))
                  (time0-today))
               (get-universal-time))))
    (apply #'send-after dt actor msg)
    ))

(defun time0-today ()
  ;; Find the Lisp Universal (local) Time at the start of today.
  (multiple-value-bind (ss mm hh dd mo yr)
      (decode-universal-time (get-universal-time))
    (declare (ignore ss mm hh))
    (encode-universal-time 0 0 0 dd mo yr)))


> On Jul 27, 2026, at 11:41, Martin Simmons <[email protected]> =
wrote:
>=20
> It is trying to define what 0 means, which is the time that the =
LispWorks OS
> process started in this case.
>=20
> I suggest just using the relative version.
>=20
> --=20
> Martin Simmons
> LispWorks Ltd
> http://www.lispworks.com/
>=20
>=20
>=20
>>>>>> On Mon, 27 Jul 2026 11:57:12 +0200, Marco Antoniotti (as marco =
dot antoniotti at unimib dot it) said:
>>=20
>> Hi
>>=20
>> I am dabbling with timers, but I am a bit confused by the =
documentation.
>>=20
>> The documentation for schedule-timer says "Schedules a timer to =
expire at a
>> given time after the start of the program."
>> The one for schedule-timer-relative says "Schedules a timer to expire =
at a
>> given time after this function is called."
>>=20
>> While the "relative" form is rather clear and intuitive (get the =
current
>> time schedule to timer x seconds later), I am a bit at a loss for the
>> absolute version.  How exactly do you get the "start of the program"?
>>=20
>> Shall I just use the relative version?
>>=20
>> Thanks
>>=20
>> --=20
>> Marco Antoniotti, Professor, Director         tel. +39 - 02 64 48 79 =
01
>> DISCo, University of Milan-Bicocca U14 2043   =
http://dcb.disco.unimib.it
>> Viale Sarca 336
>> I-20126 Milan (MI) ITALY
>>=20
>> REGAINS: https://regains.disco.unimib.it/
>>=20
>=20
> _______________________________________________
> Lisp Hug - the mailing list for LispWorks users
> [email protected]
> http://www.lispworks.com/support/lisp-hug.html


--Apple-Mail=_7638BC4F-6057-4871-B4D6-67F64CFD83D9
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=us-ascii

<html aria-label=3D"message body"><head><meta http-equiv=3D"content-type" =
content=3D"text/html; charset=3Dus-ascii"></head><body =
style=3D"overflow-wrap: break-word; -webkit-nbsp-mode: space; =
line-break: after-white-space;"><div><div><font face=3D"Monaco">All of =
mine use relative timeouts...</font></div><div><font =
face=3D"Monaco"><br></font></div><div><font =
face=3D"Monaco"><br></font></div><div><font face=3D"Monaco">(defun =
forced-send-after (dt actor &amp;rest msg)</font></div><div><span =
style=3D"font-family: Monaco;">&nbsp; (when (realp =
dt)</span></div><div><font face=3D"Monaco">&nbsp; &nbsp; (let ((timer =
(apply #'mpc:make-timer #'send-to-pool actor =
msg)))</font></div><div><font face=3D"Monaco">&nbsp; &nbsp; &nbsp; =
(mpc:schedule-timer-relative timer (max 0 dt)))</font></div><div><font =
face=3D"Monaco">&nbsp; &nbsp; ))</font></div><div><font =
face=3D"Monaco">&nbsp;&nbsp;</font></div><div><font face=3D"Monaco">(defun=
 send-after (dt actor &amp;rest msg)</font></div><div><span =
style=3D"font-family: Monaco;">&nbsp; (when (realp =
dt)</span></div><div><font face=3D"Monaco">&nbsp; &nbsp; =
(on-commit</font></div><div><font face=3D"Monaco">&nbsp; &nbsp; &nbsp; =
(apply #'forced-send-after dt actor msg))</font></div><div><font =
face=3D"Monaco">&nbsp; &nbsp; ))</font></div></div><div><font =
face=3D"Monaco"><br></font></div><div><font face=3D"Monaco">(defun =
send-at (time actor &amp;rest msg)</font></div><div><font =
face=3D"Monaco">&nbsp; ;; Assumes time, entered as hh:mm:ss, is in =
Turns.</font></div><div><font face=3D"Monaco">&nbsp; ;; 0 &lt;=3D Turns =
&lt; 1.0.</font></div><div><font face=3D"Monaco">&nbsp; ;; E.g., 12:00 =3D=
 12:00:00 =3D 1/2</font></div><div><font face=3D"Monaco">&nbsp; (let =
((dt (- (+ (round (* time 86400.))</font></div><div><font =
face=3D"Monaco">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; (time0-today))</font></div><div><font face=3D"Monaco">&nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp;(get-universal-time))))</font></div><div><font =
face=3D"Monaco">&nbsp; &nbsp; (apply #'send-after dt actor =
msg)</font></div><div><font face=3D"Monaco">&nbsp; &nbsp; =
))</font></div><div><font face=3D"Monaco"><br></font></div><div><font =
face=3D"Monaco">(defun time0-today ()</font></div><div><font =
face=3D"Monaco">&nbsp; ;; Find the Lisp Universal (local) Time at the =
start of today.</font></div><div><font face=3D"Monaco">&nbsp; =
(multiple-value-bind (ss mm hh dd mo yr)</font></div><div><font =
face=3D"Monaco">&nbsp; &nbsp; &nbsp; (decode-universal-time =
(get-universal-time))</font></div><div><font face=3D"Monaco">&nbsp; =
&nbsp; (declare (ignore ss mm hh))</font></div><div><font =
face=3D"Monaco">&nbsp; &nbsp; (encode-universal-time 0 0 0 dd mo =
yr)))</font></div><div><br></div><div><br><blockquote =
type=3D"cite"><div>On Jul 27, 2026, at 11:41, Martin Simmons =
&lt;[email protected]&gt; wrote:</div><br =
class=3D"Apple-interchange-newline"><div><div>It is trying to define =
what 0 means, which is the time that the LispWorks OS<br>process started =
in this case.<br><br>I suggest just using the relative =
version.<br><br>-- <br>Martin Simmons<br>LispWorks =
Ltd<br>http://www.lispworks.com/<br><br><br><br><blockquote =
type=3D"cite"><blockquote type=3D"cite"><blockquote =
type=3D"cite"><blockquote type=3D"cite"><blockquote type=3D"cite">On =
Mon, 27 Jul 2026 11:57:12 +0200, Marco Antoniotti (as marco dot =
antoniotti at unimib dot it) =
said:<br></blockquote></blockquote></blockquote></blockquote><br>Hi<br><br=
>I am dabbling with timers, but I am a bit confused by the =
documentation.<br><br>The documentation for schedule-timer says =
"Schedules a timer to expire at a<br>given time after the start of the =
program."<br>The one for schedule-timer-relative says "Schedules a timer =
to expire at a<br>given time after this function is =
called."<br><br>While the "relative" form is rather clear and intuitive =
(get the current<br>time schedule to timer x seconds later), I am a bit =
at a loss for the<br>absolute version. &nbsp;How exactly do you get the =
"start of the program"?<br><br>Shall I just use the relative =
version?<br><br>Thanks<br><br>-- <br>Marco Antoniotti, Professor, =
Director &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tel. +39 - 02 =
64 48 79 01<br>DISCo, University of Milan-Bicocca U14 2043 =
&nbsp;&nbsp;http://dcb.disco.unimib.it<br>Viale Sarca 336<br>I-20126 =
Milan (MI) ITALY<br><br>REGAINS: =
https://regains.disco.unimib.it/<br><br></blockquote><br>_________________=
______________________________<br>Lisp Hug - the mailing list for =
LispWorks =
users<br>[email protected]<br>http://www.lispworks.com/support/lisp-h=
ug.html<br></div></div></blockquote></div><br></body></html>=

--Apple-Mail=_7638BC4F-6057-4871-B4D6-67F64CFD83D9--

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
[email protected]
http://www.lispworks.com/support/lisp-hug.html