Skip to main content

SyncFence

Struct SyncFence 

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

A kernel sync_file fence.

Default-constructs empty, as the C++ does. Here a commit’s OUT_FENCE_PTR comes back as an OwnedFd, which SyncFence::from_owned adopts.

Implementations§

Source§

impl SyncFence

Source

pub const fn new() -> Self

An empty fence holding no descriptor.

Source

pub fn import(fd: BorrowedFd<'_>) -> Result<Self, SyncError>

Import a fence by duplicating fd.

The caller keeps ownership of fd and may close it immediately; this fence owns the duplicate. Matches the C++ import_fd, which dups for the same reason.

§Errors

SyncError::Io if dup fails — in practice EMFILE.

Source

pub const fn from_owned(fd: OwnedFd) -> Self

Take ownership of an existing descriptor without duplicating it.

The natural constructor when a commit has just produced an OUT_FENCE_PTR descriptor that nothing else holds. The C++ has no equivalent: it cannot express “this fd is yours now” in a type, so it dups unconditionally and the caller closes its copy.

Source

pub const fn is_valid(&self) -> bool

Whether this holds a real sync_file descriptor.

Source

pub fn as_fd(&self) -> Option<BorrowedFd<'_>>

The underlying descriptor, for a plane’s IN_FENCE_FD property.

Borrowed, never transferred: the kernel does not close IN_FENCE_FD, so this fence still closes it on drop.

Source

pub fn into_owned_fd(self) -> Option<OwnedFd>

Release the descriptor to the caller, consuming the fence; None if it held none.

Source

pub fn wait(&self, timeout: Duration) -> Result<(), SyncError>

Wait for the fence to signal, up to timeout.

§Interruption

A signal landing mid-wait surfaces as SyncError::Io(Errno::INTR), matching the C++, which returns EINTR to its caller. This is deliberately not the PageFlip::dispatch contract (invariant 3), which retries internally: a fence wait is a caller-owned wait, and swallowing EINTR here would make the timeout unobservable to a caller that wants to act on the signal.

§Errors
Source

pub fn merge(&mut self, other: Self) -> Result<(), SyncError>

Merge other into this fence.

The merged fence signals when both inputs have. other is consumed; this fence’s descriptor is replaced by the merged one.

§Errors

Trait Implementations§

Source§

impl Debug for SyncFence

Source§

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

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

impl Default for SyncFence

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.