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
impl SyncFence
Sourcepub fn import(fd: BorrowedFd<'_>) -> Result<Self, SyncError>
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.
Sourcepub const fn from_owned(fd: OwnedFd) -> Self
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.
Sourcepub fn as_fd(&self) -> Option<BorrowedFd<'_>>
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.
Sourcepub fn into_owned_fd(self) -> Option<OwnedFd>
pub fn into_owned_fd(self) -> Option<OwnedFd>
Release the descriptor to the caller, consuming the fence; None if it
held none.
Sourcepub fn wait(&self, timeout: Duration) -> Result<(), SyncError>
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
SyncError::Emptyif the fence holds no descriptor.SyncError::TimedOutiftimeoutelapsed first.SyncError::Ioifpollfailed.
Sourcepub fn merge(&mut self, other: Self) -> Result<(), SyncError>
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
SyncError::Emptyif either fence holds no descriptor.SyncError::MergeReturnedNothingif the ioctl reported success but produced no descriptor.SyncError::Ioif the ioctl failed.