3 ms·
Thanks for posting this to HN. I originally published this some time ago when porting a heavily-multithreaded library from Windows to Mac and Linux. It should r
by ComputerGuru 11y ago
Thanks for posting this to HN. I originally published this some time ago when porting a heavily-multithreaded library from Windows to Mac and Linux. It should run on Windows/Linux/Mac/FreeBSD/etc. and it's been vetted and tested over the years. I even came across some backtraces from Steam's Mac/Linux app that indicated they were using my code a few years back, so there's that.
I'm a bit ashamed that I opted to write it in C++ originally. It doesn't have much in terms of standard library dependencies (just dequeue), but in the process of porting it to C I decided to also change how the inner notifications system works with regards to the cleanup of allocated memory for completed waits and now I'm stuck on a particularly nasty decision of whether to add a mutex, use reference counting, or let memory grow until an event is destroyed... and so the code is still C++ :)
- arithma 11y agoWhy ashamed with writing in C++?
- ComputerGuru 11y agoJust because synchronization primitives are pretty low level so it would be nice for it to compile as C code. I should just expose the API without name mangling, I suppose. (I forgot to add: the library is also free of spurious-wakeups, which I feel is massive gotcha in pthreads.)