@@ -17,8 +17,30 @@ enum : unsigned {
1717
1818IPC_EXPORT id_t acquire (char const * name, std::size_t size, unsigned mode = create | open);
1919IPC_EXPORT void * get_mem (id_t id, std::size_t * size);
20+
21+ // Release shared memory resource and clean up disk file if reference count reaches zero.
22+ // This function decrements the reference counter. When the counter reaches zero, it:
23+ // 1. Unmaps the shared memory region
24+ // 2. Removes the backing file from disk (shm_unlink on POSIX)
25+ // 3. Frees the id structure
26+ // After calling this function, the id becomes invalid and must not be used again.
27+ // Returns: The reference count before decrement, or -1 on error.
2028IPC_EXPORT std::int32_t release (id_t id) noexcept ;
29+
30+ // Release shared memory resource and force cleanup of disk file.
31+ // This function calls release(id) internally, then unconditionally attempts to
32+ // remove the backing file. WARNING: Do NOT call this after release(id) on the
33+ // same id, as the id is already freed by release(). Use this function alone,
34+ // not in combination with release().
35+ // Typical use case: Force cleanup when you want to ensure the disk file is removed
36+ // regardless of reference count state.
2137IPC_EXPORT void remove (id_t id) noexcept ;
38+
39+ // Remove shared memory backing file by name.
40+ // This function only removes the disk file and does not affect any active memory
41+ // mappings or id structures. Use this for cleanup of orphaned files or for explicit
42+ // file removal without affecting runtime resources.
43+ // Safe to call at any time, even if shared memory is still in use elsewhere.
2244IPC_EXPORT void remove (char const * name) noexcept ;
2345
2446IPC_EXPORT std::int32_t get_ref (id_t id);
0 commit comments