tur/image
application image dumps via serializable continuations.
Since: Phase AI (application-image-dumps-plan)
image/build-stamp
(image/build-stamp :)
SHA-256 (32 bytes) of the running executable.
A malloc'd 32-byte buffer (caller frees with image/free-stamp) as an int pointer, or 0 if the executable image could not be read.
Since: Phase AI
image/free-stamp
(image/free-stamp [p : int] :)
free a build stamp returned by image/build-stamp.
image/exists?
(image/exists? [path : cstr] :)
1 if a readable file exists at path, else 0.
image/hook-registry
(image/hook-registry [op : int arg : int] :)
backing store for reload/finalize hooks (internal).
image/register-reload-hook!
(image/register-reload-hook! [^fat f : (fn [])
install a hook run on warm start before resume.
| f | a zero-arg hook (fn [] int); the return value is ignored |
The number of reload hooks registered so far.
Since: Phase AI (AI5.1)
image/run-reload-hooks
(image/run-reload-hooks :)
invoke every registered reload hook in order.
Since: Phase AI (AI5.1)
image/register-finalize-hook!
(image/register-finalize-hook! [^fat f : (fn [])
install a hook run just before a save.
| f | a zero-arg hook (fn [] int); the return value is ignored |
The number of finalize hooks registered so far.
Since: Phase AI (AI5.3)
image/run-finalize-hooks
(image/run-finalize-hooks :)
invoke every registered finalize hook in order.
Since: Phase AI (AI5.3)
defimage-reload-hook
(defimage-reload-hook [name body])
define a named reload hook function.
(defimage-reload-hook reopen-log
(do (reopen-the-log!) 0))
;; ... in main, before with-image-cache-after-init:
(image/register-reload-hook! reopen-log)
Since: Phase AI (AI5.1)
defimage-finalize-hook
(defimage-finalize-hook [name body])
define a named finalize hook function.
Since: Phase AI (AI5.3)
image/save-cont-to-file!
(image/save-cont-to-file! [path : cstr k ptr<void> stamp : int] :)
serialise continuation k and write it to path.
| path | destination path | |
| k | the serial-continuation handle from serial-shift | |
| stamp | 32-byte build stamp pointer (image/build-stamp), or 0 to zero-fill |
1 on success, 0 on failure (nil k, unwritable path, short write).
Since: Phase AI
image/loadable?
(image/loadable? [path : cstr stamp : int] :)
1 if path is a structurally valid image for `stamp`.
Since: Phase AI
image/load-resume-file!
(image/load-resume-file! [path : cstr stamp : int v : int] :)
read + validate an image and resume it on v.
| path | source path | |
| stamp | 32-byte build-stamp pointer to enforce, or 0 to skip the check | |
| v | the value to resume the captured continuation with |
The resumed continuation's value on success (control transfers into the captured tail), or 0 on any validation/I-O failure (no resume occurs).
Since: Phase AI
save-image!
(save-image! [path : cstr] :)
capture the current continuation and write it to path.
Since: Phase AI
load-image!
(load-image! [path : cstr] :)
read an image and resume the continuation it holds.
Since: Phase AI
with-image-cache-after-init
(with-image-cache-after-init [path init loop])
the primary warm-start combinator (AIQ1).
| path | image cache path | |
| init | a fn [] run only on cold start (expensive setup) | |
| loop | a fn [] run on both paths (the steady-state work) | |
| This is a macro, not a function: `init` and `loop` are spliced as call | ||
| targets so the captured continuation tail `(loop)` is a call to a *named* | ||
| top-level function. The serial-shift collector reconstructs frames by | ||
| stable name, so the tail cannot be a heap closure -- it must be a named | ||
| (serializable) continuation. Pass top-level `defn` names for init and loop. | ||
| For a *cross-process* warm start to resume correctly, loop must reduce to a | ||
| serializable continuation (named frames, int/cstr/Serializable envs) -- the | ||
| same constraint Serializable continuations impose on serial-shift. |
Since: Phase AI
with-image-cache
(with-image-cache [path : cstr ^fat body : (fn [])
single-body warm-start wrapper.
Since: Phase AI