Open a section from the left

Open a shared desk

One file mapping holds the desk. The writer creates it. Other processes attach to the same path.


pitlane::MapInfo map{};
if (pitlane::map_create("desk.bin", pitlane::desk_bytes(), &map) != 0) return 1;
pitlane::Desk* desk = pitlane::desk_view(&map, 1);
if (!desk) return 1;

map_create creates or extends the file and does not wipe an existing mapping. The default MapOpt uses explicit huge pages only: length rounds to Hugepagesize, and the file is placed on hugetlbfs (default /dev/hugepages as pitlane_<basename>), or at the caller path when that path is already on hugetlbfs. THP / MADV_HUGEPAGE are never used. When explicit pages are unavailable the mapping falls back to the caller path and sets MapInfo::fallback. mlock is attempted by default; numa_node >= 0 binds the range with MPOL_BIND. desk_view returns the desk only when the magic is PITLANE1 and the layout version is kDeskVersion, which is 5. The second argument formats a still-blank file when it is non-zero. A file with the wrong magic is left untouched and the call returns null. After the magic is written, do not format the mapping again.

Another process attaches with map_attach and passes 0 to desk_view (same logical path so both sides resolve the same hugetlbfs file). map_release unmaps; if the mapping was locked it calls munlock first, then closes the file. Each ring has one writer. Readers do not share a cursor.

desk->clock_us is the session clock in microseconds. DeskLoop::beat stores the time it is given there.