Skip to main content

Module reads

Module reads 

Source
Expand description

The read kernel: what a page reads from the host (a status’s value, a list’s rows), kept in one place and read away from the UI thread.

Experimental: may change in any release (docs/stability.md).
  • Keyed: a read is a command and its arguments. Two pages asking the same thing share one entry, and one request while it is in flight.
  • At once: ReadKernel::read never waits. It answers what it holds now with a ReadState: Pending (nothing yet), Fresh, Refreshing (the last value, known to be out of date, while a new one is read) or Failed (the last read failed; the value before it, if any, is kept).
  • Stale while revalidating: a value is never dropped for being old. Out of date, it is shown until the new one comes.
  • Policies: the host says, per command, how long a value stays fresh (ReadPolicy::fresh_for) and which events make it out of date (ReadPolicy::invalidated_by, name or prefix.*). A value past its freshness is read again in the background while it is shown, and keeps the state Fresh meanwhile; one an event made out of date is Refreshing. Without a freshness, a value stays fresh until an event or ReadKernel::invalidate_all.
  • The host contract: the host gives a ReadTransport, called on a thread of the kernel’s (at once on the web, or when no thread starts). The kernel asks the window to repaint when an answer comes, and when a value shown will be past its freshness.

The Settings app reads through it the commands its transport serves (crate::admin::Admin::attach_reads); other commands keep being run on the command bus.

The cache is a map under a lock, not a cache crate: the entries are a page’s reads (tens, not millions), they are never evicted (a stale value is what is shown while revalidating), and in-flight sharing must not block the caller, which the caches surveyed (moka, quick_cache) do by waiting on the first loader.

Structs§

Read
A read’s answer now.
ReadKernel
The kernel: the host’s ReadTransport, the policies and the values read. Shared (Arc); every method takes &self.
ReadPolicy
How a command’s reads are kept.

Enums§

ReadState
Where a read stands.

Traits§

ReadTransport
What the host reads for the kernel: its node, its database, a service. Called away from the UI thread; may take its time.

Functions§

matches
Whether name matches pattern (name, or prefix.*).