Primary application-facing process API for one GPUI application and display.
A runtime starts the renderer-independent GPUI.Session, owns the configured
GPUI.Display, synchronizes authoritative snapshots, drains strict typed
display events, and publishes completed updates to subscribers. Applications
normally supervise their GPUI.Application, whose child specification starts
this process; direct GPUI.Session use is reserved for remote hosting and
custom display infrastructure.
Use this module for application operations such as snapshots, resources, dynamic windows, view messages, subscriptions, and frame barriers.
Options
:app- requiredGPUI.Applicationmodule;:args- application mount argument, defaulting to[];:display- display module, defaulting toGPUI.Display.Native;:display_opts- options passed to the display;:poll_interval- positive milliseconds ornilto disable polling, defaulting to16;:name- optional runtime process name.
Summary
Functions
Waits until a complete display frame follows the current window state.
Waits for a display frame completed after the supplied generation.
Returns a specification to start this module under a supervisor.
Closes a declarative window by key or session ID and synchronizes the display.
Validates and dispatches one explicit typed event and synchronizes the resulting snapshot.
Drains display events, applies them to the session, and synchronizes the result.
Drops a session resource and synchronizes the resulting snapshot.
Returns the bounded history of handled display events.
Returns the latest completed display frame generation for a window.
Returns stable runtime topology and synchronization information.
Injects an event into the active display queue without dispatching it immediately.
Adds a keyed declarative window and synchronizes it to the display.
Stores a session resource and synchronizes the resulting snapshot.
Rerenders every window from its current module and assigns, then synchronizes the display.
Requests a display frame for the current snapshot without changing application state.
Delivers an OTP message to a window's root view and synchronizes the display.
Returns the current authoritative session snapshot.
Starts a runtime linked to the caller.
Subscribes the calling process to synchronized runtime updates.
Unsubscribes the calling process from runtime updates.
Returns the runtime session's declarative windows.
Types
@type state() :: %{ application: module(), identity: GPUI.Application.Identity.t() | nil, session: pid(), display: pid(), display_module: module(), events: [map()], poll_interval: pos_integer() | nil, revision: non_neg_integer(), subscribers: %{required(pid()) => reference()}, unsynchronized?: boolean() }
Functions
@spec await_frame(GenServer.server(), pos_integer(), pos_integer()) :: :ok | {:error, term()}
Waits until a complete display frame follows the current window state.
@spec await_frame_after( GenServer.server(), pos_integer(), non_neg_integer(), pos_integer() ) :: :ok | {:error, term()}
Waits for a display frame completed after the supplied generation.
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec close_window(GenServer.server(), GPUI.WindowSpec.key() | pos_integer()) :: {:ok, GPUI.Snapshot.t()} | {:error, GPUI.Session.topology_error()}
Closes a declarative window by key or session ID and synchronizes the display.
@spec dispatch_event(GenServer.server(), map()) :: {map(), GPUI.Snapshot.t()} | {:error, term()}
Validates and dispatches one explicit typed event and synchronizes the resulting snapshot.
@spec drain_events(GenServer.server()) :: [map()] | {:error, term()}
Drains display events, applies them to the session, and synchronizes the result.
@spec drop_resource(GenServer.server(), String.Chars.t()) :: :ok | {:error, term()}
Drops a session resource and synchronizes the resulting snapshot.
@spec events(GenServer.server()) :: [map()]
Returns the bounded history of handled display events.
@spec frame_token(GenServer.server(), pos_integer()) :: {:ok, non_neg_integer()} | {:error, term()}
Returns the latest completed display frame generation for a window.
@spec info(GenServer.server()) :: map()
Returns stable runtime topology and synchronization information.
@spec inject_event(GenServer.server(), map()) :: {:ok, term()} | {:error, term()}
Injects an event into the active display queue without dispatching it immediately.
@spec open_window(GenServer.server(), GPUI.WindowSpec.t()) :: {:ok, pos_integer(), GPUI.Snapshot.t()} | {:error, GPUI.Session.topology_error()}
Adds a keyed declarative window and synchronizes it to the display.
@spec put_resource(GenServer.server(), String.Chars.t(), map()) :: :ok | {:error, term()}
Stores a session resource and synchronizes the resulting snapshot.
@spec refresh(GenServer.server()) :: {:ok, GPUI.Snapshot.t()} | {:error, term()}
Rerenders every window from its current module and assigns, then synchronizes the display.
@spec request_frame(GenServer.server()) :: :ok | {:error, term()}
Requests a display frame for the current snapshot without changing application state.
@spec send_view(GenServer.server(), pos_integer(), term()) :: {:ok, GPUI.Snapshot.t()} | {:error, term()}
Delivers an OTP message to a window's root view and synchronizes the display.
@spec snapshot(GenServer.server()) :: GPUI.Snapshot.t()
Returns the current authoritative session snapshot.
@spec start_link(keyword()) :: GenServer.on_start()
Starts a runtime linked to the caller.
@spec subscribe(GenServer.server()) :: :ok
Subscribes the calling process to synchronized runtime updates.
@spec unsubscribe(GenServer.server()) :: :ok
Unsubscribes the calling process from runtime updates.
@spec windows(GenServer.server()) :: [GPUI.WindowSpec.t()]
Returns the runtime session's declarative windows.