libcamera  v0.1.0+127-8e215127
Supporting cameras in Linux since 2019
Public Member Functions | List of all members
libcamera::Fence Class Reference

Synchronization primitive to manage resources. More...

Public Member Functions

 Fence (UniqueFD fd)
 Create a Fence. More...
bool isValid () const
 Check if a Fence is valid. More...
const UniqueFDfd () const
 Retrieve a constant reference to the file descriptor. More...
UniqueFD release ()
 Release the ownership of the file descriptor. More...

Detailed Description

Synchronization primitive to manage resources.

The Fence class models a synchronization primitive that can be used by applications to explicitly synchronize resource usage, and can be shared by multiple processes.

Fences are most commonly used in association with frame buffers. A FrameBuffer can be associated with a Fence so that the library can wait for the Fence to be signalled before allowing the camera device to actually access the memory area described by the FrameBuffer.

See also

By using a fence, applications can then synchronize between frame buffer consumers and producers, as for example a display device and a camera, to guarantee that a new data transfers only happen once the existing frames have been displayed.

A Fence can be realized by different event notification primitives, the most common of which is represented by waiting for read events to happen on a kernel sync file. This is currently the only mechanism supported by libcamera, but others can be implemented by extending or subclassing this class and implementing opportune handling in the core library.

Constructor & Destructor Documentation

◆ Fence()

libcamera::Fence::Fence ( UniqueFD  fd)

Create a Fence.

[in]fdThe fence file descriptor

The file descriptor ownership is moved to the Fence.

Member Function Documentation

◆ fd()

libcamera::Fence::fd ( ) const

Retrieve a constant reference to the file descriptor.

A const reference to the fence file descriptor

◆ isValid()

libcamera::Fence::isValid ( ) const

Check if a Fence is valid.

A Fence is valid if the file descriptor it wraps is valid.

True if the Fence is valid, false otherwise

◆ release()

libcamera::Fence::release ( )

Release the ownership of the file descriptor.

Release the ownership of the wrapped file descriptor by returning it to the caller.

The wrapper UniqueFD

The documentation for this class was generated from the following files: