nim-works / loony

A high throughput MPMC lock-free queue based on a paper by Giersch, Nolte et al implemented in pure Nim.
https://nim-works.github.io/loony/
MIT License
64 stars 4 forks source link

[MacOS/Darwin] Emulating Futex behaviour #21

Closed shayanhabibi closed 2 years ago

shayanhabibi commented 2 years ago

Issue

Currently I use linux futex and windows waitonaddress to manage backpressure when using Wards and Loony as a threadpool queue.

Mac/Darwin do not have primitives or APIs that are similar.

Solutions

At the moment, I can only think of using conditions and locks.

shayanhabibi commented 2 years ago

Have decided on using Darwin ulock primitives which are basically futexes.

Issue being they are private functions.

proc ulock_wait*(operation: uint32, address: pointer, value: uint64, timeout: uint32): cint {.importc: "__ulock_wait", cdecl.}