Skip to main content

FrameLifecycle

Struct FrameLifecycle 

Source
pub struct FrameLifecycle { /* private fields */ }
Expand description

Owns the state a commit reconciles: the release ring, the armed-flip tripwire, and whether the scene is suspended.

Implementations§

Source§

impl FrameLifecycle

Source

pub const fn new() -> Self

A fresh lifecycle with nothing in flight.

Source

pub const fn is_suspended(&self) -> bool

Whether the scene is suspended and short-circuiting commits.

Source

pub const fn has_pending_flip(&self) -> bool

Whether a page-flip event is armed and undispatched.

Invariant 5. Dropping the scene while this is true tears down a framebuffer the flip still references.

Source

pub fn buffers_in_flight(&self) -> usize

How many buffers are held in flight.

Source

pub const fn flip_landed(&mut self)

Record that the armed page-flip event was dispatched.

Source

pub const fn resume(&mut self)

Lift a suspension after the session resumes.

Source

pub fn finalize( &mut self, kind: CommitKind, result: KernelResult, acquisitions: Vec<Acquisition>, report: CommitReport, release_fence: Option<&SyncFence>, wants_fence: impl FnMut(LayerId) -> bool, ) -> FrameOutcome

Reconcile scene state with the kernel’s answer.

§The rules, and why each is where it is
  • Success on a real commit rotates the release ring and returns the buffers two commits deep — invariant 1.
  • Any failure returns this frame’s buffers at once, because no flip is in flight to gate them on — invariant 2.
  • Only NotMaster suspends. A non-EACCES rejection drops the frame and heals on the next one; suspending on it would take a recoverable stumble and stop the scene. The C++ states this as an external contract, and self-healing producer rings depend on it.
  • A rejected fast-path frame invalidates the cached allocation. Invariant 4’s safety net: the kernel refused a frame whose TEST_ONLY was skipped, so the cache is no longer trustworthy. The frame is dropped but heals — the failure mode is never corruption. A recurring rejection here means a property was misclassified as content, which is why it is worth warning about once.
  • A test commit returns its buffers at once and changes nothing else: it applied nothing to hardware.
Source

pub const fn has_warned_fast_path_reject(&self) -> bool

Whether a fast-path rejection has been warned about yet. Set by finalize, which logs the first one and no other.

Source

pub fn release_displaced(&mut self, commit_seq: u64) -> Released

The buffers the flip of real commit commit_seq took off screen, for handing back at that flip rather than at the next commit.

Nothing unless commit_seq names the most recent real commit: after an older one, a newer commit has rotated buffers still on screen into the generation this would release. So a late or repeated call cannot release a buffer still on screen. Port of upstream’s release_displaced (ee90026).

Source

pub fn drain(&mut self) -> Released

Hand back every held buffer, for teardown, pause, or rebind.

Invariant 5. Does not wait on the kernel. Landing an armed flip first is the caller’s job — has_pending_flip says whether one is outstanding.

Trait Implementations§

Source§

impl Debug for FrameLifecycle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FrameLifecycle

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.