Skip to content

feat(event): add c_event cross-platform multi-event wait primitive#1

Merged
RiantZ merged 6 commits into
mainfrom
lau/event
Jun 24, 2026
Merged

feat(event): add c_event cross-platform multi-event wait primitive#1
RiantZ merged 6 commits into
mainfrom
lau/event

Conversation

@RiantZ

@RiantZ RiantZ commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Port the P7 PMEvent (CMEvent/IMEvent) wait-any primitive into kit as c_event, adapted to project conventions. Manages a set of auto-reset, manual-reset and counting events and waits until any one is signaled, returning its index.

  • Windows: native WaitForMultipleObjects
  • Linux: POSIX unnamed semaphore + pthread mutex (original design)
  • macOS: GCD dispatch_semaphore (no unnamed POSIX semaphores there), clock-safe relative timeouts mirroring the Linux algorithm
    Replaces the va_list Init() with a type-safe array-based init().
    Wired into CMake per platform, exposed via kit.h, covered by gtest.

RiantZ added 6 commits April 27, 2026 10:53
Introduce kit::time with steady_now_ns() for high-resolution
monotonic timestamps on Linux (clock_gettime), macOS
(mach_absolute_time), and Windows (QueryPerformanceCounter).

Made-with: Cursor
Add CMAKE_EXPORT_COMPILE_COMMANDS to macOS and Linux presets
so clangd can provide accurate diagnostics and navigation.

Made-with: Cursor
Provides get_process_id(), get_process_name(), get_host_name() across
macOS, Linux, and Windows to centralise system info queries in kit.

Made-with: Cursor
Header-only bswap16/32/64 wrapping compiler intrinsics for GCC, Clang,
and MSVC to support little-endian wire format encoding.

Made-with: Cursor
get_system_time() returns 100ns intervals since 1601-01-01 UTC using
GetSystemTimePreciseAsFileTime on Windows and clock_gettime(CLOCK_REALTIME)
on POSIX. get_utc_offset_seconds() returns the local UTC offset.

Made-with: Cursor
- Windows: native WaitForMultipleObjects
- Linux: POSIX unnamed semaphore + pthread mutex (original design)
- macOS: GCD dispatch_semaphore (no unnamed POSIX semaphores there),
  clock-safe relative timeouts mirroring the Linux algorithm
@RiantZ
RiantZ merged commit c03bf0e into main Jun 24, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant