behn: improve scry interface

No longer abuse the desk field, instead making use of the path. Reject
any scries outside of the local ship, empty desk and current time as
invalid.

Expose ducts only under a debug endpoint, nothing else should care about
being able to inspect them.

Add scry endpoints for the very next timer (if any), and all timers up
to and including a specified timestamp.
This commit is contained in:
Fang 2020-06-24 16:34:36 +02:00
parent f714d90b15
commit a94285208a
No known key found for this signature in database
GPG Key ID: EB035760C1BBA972
3 changed files with 43 additions and 8 deletions

View File

@ -767,7 +767,7 @@
++ v-behn
|%
++ timers
(scry ,(list [date=@da =duct]) %b %timers ~)
(scry ,(list [date=@da =duct]) %bx %$ /debug/timers)
--
::
:: clay

View File

@ -1,5 +1,5 @@
:: Find list of currently running Behn timers
:- %say
|= *
|= [[now=@da *] *]
:- %tang
[>.^((list [date=@da =duct]) %b /=timers=)< ~]
[>.^((list [date=@da =duct]) %bx /=//(scot %da now)/debug/timers)< ~]

View File

@ -389,18 +389,53 @@
++ scry
|= [fur=(unit (set monk)) ren=@tas why=shop syd=desk lot=coin tyl=path]
^- (unit (unit cage))
:: only respond for the local identity, %$ desk, current timestamp
::
?. ?=(%& -.why)
?. ?& =(&+our why)
=([%$ %da now] lot)
=(%$ syd)
==
~
?. ?=(%timers syd)
[~ ~]
=/ tiz=(list [@da duct])
:: /bx/debug/timers (list [@da duct]) all timers and their ducts
:: /bx/timers (list @da) all timer timestamps
:: /bx/timers/next (unit @da) the very next timer to fire
:: /bx/timers/[da] (list @da) all timers up to and including da
::
?. ?=(%x ren) ~
?+ tyl [~ ~]
[%debug %timers ~]
:^ ~ ~ %noun
!> ^- (list [@da duct])
%- zing
%+ turn (tap:timer-map timers)
|= [date=@da q=(qeu duct)]
%+ turn ~(tap to q)
|=(d=duct [date d])
[~ ~ %noun !>(tiz)]
::
[%timers ~]
:^ ~ ~ %noun
!> ^- (list @da)
%- zing
%+ turn (tap:timer-map timers)
|= [date=@da q=(qeu duct)]
(reap ~(wyt in q) date)
::
[%timers %next ~]
:^ ~ ~ %noun
!> ^- (unit @da)
(bind (peek:timer-map timers) head)
::
[%timers @ ~]
?~ til=(slaw %da i.t.tyl)
[~ ~]
:^ ~ ~ %noun
!> ^- (list @da)
%- zing
%+ turn (tap:timer-map timers)
|= [date=@da q=(qeu duct)]
?: (gth date u.til) ~
(reap ~(wyt in q) date)
==
::
++ stay state
++ take