36 static constexpr std::size_t
SIZE =
sizeof(T);
48 template<
class... Args>
50 : name_(name), obj_(nullptr)
55 ret = memfd_create(name_.c_str(), MFD_CLOEXEC);
63 ret = ftruncate(fd_.
get(),
SIZE);
67 mem = mmap(
nullptr,
SIZE, PROT_READ | PROT_WRITE, MAP_SHARED,
69 if (mem == MAP_FAILED)
72 obj_ =
new (mem) T(std::forward<Args>(args)...);
81 this->name_ = std::move(rhs.name_);
82 this->fd_ = std::move(rhs.fd_);
83 this->obj_ = rhs.obj_;
104 this->name_ = std::move(rhs.name_);
105 this->fd_ = std::move(rhs.fd_);
106 this->obj_ = rhs.obj_;
166 explicit operator bool()
const
Utilities to help constructing class interfaces.
#define LIBCAMERA_DISABLE_COPY(klass)
Disable copy construction and assignment of the klass.
Definition class.h:27
RAII-style wrapper for file descriptors.
Definition shared_fd.h:17
int get() const
Retrieve the numerical file descriptor.
Definition shared_fd.h:30
bool isValid() const
Check if the SharedFD instance is valid.
Definition shared_fd.h:29
Helper class for shared memory allocations.
Definition shared_mem_object.h:31
const T * operator->() const
Operator-> for SharedMemObject.
Definition shared_mem_object.h:126
SharedMemObject(SharedMemObject< T > &&rhs)
Move constructor for SharedMemObject.
Definition shared_mem_object.h:79
SharedMemObject(const std::string &name, Args &&...args)
Contstructor for the SharedMemObject.
Definition shared_mem_object.h:49
const SharedFD & fd() const
Gets the file descriptor for the underlaying storage file.
Definition shared_mem_object.h:156
T * operator->()
Operator-> for SharedMemObject.
Definition shared_mem_object.h:116
const T & operator*() const
Operator* for SharedMemObject.
Definition shared_mem_object.h:146
static constexpr std::size_t SIZE
The size of the object that is going to be stored here.
Definition shared_mem_object.h:36
T & operator*()
Operator* for SharedMemObject.
Definition shared_mem_object.h:136
Top-level libcamera namespace.
Definition backtrace.h:17