61 std::lock_guard<std::mutex> lock(mtx);
63 key_t key = ftok(path.c_str(),
'A');
67 return shmget(key,
sizeof(T), 0666 | IPC_CREAT);
88 std::lock_guard<std::mutex> lock(mtx);
90 any ptr = shmat(shmid,
nullptr, 0);
94 return static_cast<T*
>(ptr);
115 std::lock_guard<std::mutex> lock(mtx);
117 if(shmdt(data) == -1)
140 std::lock_guard<std::mutex> lock(mtx);
141 return shmctl(shmid, IPC_RMID,
nullptr) == -1;
i32 ldvc_create_ipc(std::mutex &mtx, string path)
Creates a new IPC shared memory segment.
u8 ldvc_detach_ipc(T *data, std::mutex &mtx)
Detaches from an IPC shared memory segment.
bool ldvc_destroy_ipc(i32 shmid, std::mutex &mtx)
Destroys an IPC shared memory segment.
T * ldvc_attach_ipc(i32 shmid, std::mutex &mtx)
Attaches to an existing IPC shared memory segment.
Defines common types used throughout the library.
unsigned char u8
Unsigned integer types.
void * any
Alias for void pointer.