No matching definitions.

tur/image

stdlib/image.tur

application image dumps via serializable continuations.

Since: Phase AI (application-image-dumps-plan)

defn

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

defn

image/free-stamp

(image/free-stamp [p : int] :)

free a build stamp returned by image/build-stamp.

defn

image/exists?

(image/exists? [path : cstr] :)

1 if a readable file exists at path, else 0.

defn

image/hook-registry

(image/hook-registry [op : int arg : int] :)

backing store for reload/finalize hooks (internal).

defn

image/register-reload-hook!

(image/register-reload-hook! [^fat f : (fn [])

install a hook run on warm start before resume.

fa zero-arg hook (fn [] int); the return value is ignored

The number of reload hooks registered so far.

Since: Phase AI (AI5.1)

defn

image/run-reload-hooks

(image/run-reload-hooks :)

invoke every registered reload hook in order.

Since: Phase AI (AI5.1)

defn

image/register-finalize-hook!

(image/register-finalize-hook! [^fat f : (fn [])

install a hook run just before a save.

fa zero-arg hook (fn [] int); the return value is ignored

The number of finalize hooks registered so far.

Since: Phase AI (AI5.3)

defn

image/run-finalize-hooks

(image/run-finalize-hooks :)

invoke every registered finalize hook in order.

Since: Phase AI (AI5.3)

defmacro

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)

defmacro

defimage-finalize-hook

(defimage-finalize-hook [name body])

define a named finalize hook function.

Since: Phase AI (AI5.3)

defn

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.

pathdestination path
kthe serial-continuation handle from serial-shift
stamp32-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

defn

image/loadable?

(image/loadable? [path : cstr stamp : int] :)

1 if path is a structurally valid image for `stamp`.

Since: Phase AI

defn

image/load-resume-file!

(image/load-resume-file! [path : cstr stamp : int v : int] :)

read + validate an image and resume it on v.

pathsource path
stamp32-byte build-stamp pointer to enforce, or 0 to skip the check
vthe 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

defn

save-image!

(save-image! [path : cstr] :)

capture the current continuation and write it to path.

Since: Phase AI

defn

load-image!

(load-image! [path : cstr] :)

read an image and resume the continuation it holds.

Since: Phase AI

defmacro

with-image-cache-after-init

(with-image-cache-after-init [path init loop])

the primary warm-start combinator (AIQ1).

pathimage cache path
inita fn [] run only on cold start (expensive setup)
loopa 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

defn

with-image-cache

(with-image-cache [path : cstr ^fat body : (fn [])

single-body warm-start wrapper.

Since: Phase AI