Sprites.Control (Sprites v0.1.0)

View Source

Module-level pool management for control connections.

Uses ETS tables to store per-sprite pools and control support flags. Pools are created lazily on first checkout and cached for reuse.

Summary

Functions

Returns a control connection to the pool for the given sprite.

Checks out a control connection for the given sprite.

Closes all control connections for the given sprite and removes the pool.

Returns whether control mode is believed to be supported for the given sprite.

Ensures ETS tables exist. Safe to call multiple times.

Marks a sprite as not supporting control mode.

Functions

checkin(sprite, conn_pid)

@spec checkin(Sprites.Sprite.t(), pid()) :: :ok

Returns a control connection to the pool for the given sprite.

checkout(sprite)

@spec checkout(Sprites.Sprite.t()) :: {:ok, pid()} | {:error, term()}

Checks out a control connection for the given sprite.

Creates a pool if one doesn't exist yet.

close(sprite)

@spec close(Sprites.Sprite.t()) :: :ok

Closes all control connections for the given sprite and removes the pool.

control_supported?(sprite)

@spec control_supported?(Sprites.Sprite.t()) :: boolean()

Returns whether control mode is believed to be supported for the given sprite.

Returns true by default (until mark_unsupported/1 is called).

ensure_tables()

@spec ensure_tables() :: :ok

Ensures ETS tables exist. Safe to call multiple times.

mark_unsupported(sprite)

@spec mark_unsupported(Sprites.Sprite.t()) :: :ok

Marks a sprite as not supporting control mode.

Prevents future checkout attempts from trying the control endpoint.