@@ -1,246 +0,0 @@
2−title = "API Reference"
7−In this document we describe the public interface for Behn. Namely, we describe
8−each `task` that Behn can be `pass`ed, and which `gift`(s) Behn can `give` in return.
15−Each time you start your Urbit, the Arvo kernel calls the `%born` task for Behn. When
16−called, Behn gets the current time from Unix and updates its list of timers
27−`%born` does not return a `gift`.
32−`%crud` is called whenever an error involving Behn occurs, such as trying to
33−`%wake` a program that has crashed.
35−When called, it checks to see if the set of timers is empty. If so, it prints
36−an error report containing `error`, otherwise it passes the error to `+wake`.
43−Here, `tag` is a `@tas` denoting the type of error, and `error` is an error message.
48−[%wake %behn-crud-no-timer tag error]
51−If the set of timers is nonempty when Behn is `%pass`ed a `%crud` `task`, Behn
52−`%give`s a `%wake` `card` containing the error to the next client in the set of timers.
57−The most common error that occurs is when Behn tries to `%wake` up a program that has crashed. When this happens
58−the entire event (i.e. sequence of `move`s) that led up to the `%wake` is thrown
59−away, and Vere then causes the kernel to `pass` Behn a `%crud` `task` containing
65−`%drip` allows one to delay a `gift` until a timer set for `now` fires.
67−A Client `%slip`s Behn a `%drip` task wrapping a `gift` to be `give`n to a Target.
68−This launches a sequence of `move`s as written here:
71−Client -- %slip %drip --> Behn -- %pass %wait --> Behn -- %give %wake --> Behn -- %give %meta --> Target
73−Here the `%meta` `move` is a wrapper for the `%gift` inside of the initial `%drip` wrapper.
75−`%drip` only handles `gift`s, and can only schedule `gift`s for as soon as
76−possible after the prescribed timer fires.
85−`%drip` takes in a `%give` `move` in a `vase`.
89−In response to a `%drip` `task`, Behn will `%pass` a `%wait` to itself, which
90−then triggers a `%wake` `gift` to itself, which then causes Behn to `%give` a `%meta` `gift` containing
91−the `gift` originally `%give`n to Behn when `%drip` was first called. That makes
92−Behn its own client for `%drip`.
97−Say an app (the Target) is subscribed to updates from Clay (the Client). If Clay `%give`s
98−updates to the app directly and the app crashes, this may cause Clay to crash as
99−well. If instead Clay `%pass`es Behn a `%drip` `task` wrapping the update
100−`gift`, Behn will set a timer for `now` that, when fired, will cause the update
101−`gift` to be given. If it causes a crash then it will have been in response to
102−the `%drip` move, thereby isolating Clay from the crash. Thus `%drip` acts as a sort of buffer against cascading
103−sequences of crashes.
109−Immediately gives back an input move.
117−Behn takes in a `move` contained in a `vase`.
125−Behn returns the input `move` as a `%meta` `gift`.
131−Cancels a timer that was previously set.
133−Behn takes in a `@da` and cancels the timer at that time if it exists, then
134−adjusts the next wakeup call from Unix if necessary.
145−This `task` returns no `gift`s.
151−This `task` is sent by the interpreter in order to free up memory.
152− This `task` is empty for Behn, since it is not a good idea to forget your timers.
156−This `task` has no arguments.
160−This task returns nothing.
164−This `task` informs the vane that the kernel has been upgraded. Behn does not do
165−anything in response to this.
169−This `task` has no arguments.
173−This `task` returns nothing.
179−This `task` takes in a `@da` which Behn then adds to `timers.state`, the list of timers.
189−This `task` returns a `%wake` `gift` once the timer has fired.
194−This `task` is sent by the kernel when the Unix timer tells the kernel that it
195−is time for Behn to wake up. This is often caused by a `%doze` `gift` that
196−Behn originally sent to the kernel that is then forwarded to Unix, which is
197−where the real timekeeping occurs.
199−Upon receiving this `task`, Behn processes the elapsed timer and then sets
202−`%wake` is also a `gift` that Behn can `%give`. This is done to inform other
203−vanes or apps that a timer has expired, and may include an error message.
207−As a `task`, `%wake` takes in `~`.
209−As a `gift`, `%wake` may include an error message.
218−In response to receiving this `task`, Behn may `%give` a `%doze` `gift`
219−containing the `@da` of the next timer to elapse. Behn may also `%give` a
220−`%wake` `gift` to itself.
226−This `task` asks Behn to product a memory usage report.
230−This `task` has no arguments.
238− :~ timers+&+timers.state
242−When Behn is `%pass`ed this `task`, it will `%give` a `%mass` `gift` in response
243−containing Behn's current memory usage.