c11threads
c11threads copied to clipboard
Windows threads support
Would be really nice to see win threads support here! I might do it because I'm quite desperate looking for C-only cross-platform threading lib.
I might be missing something, but what would networking have to do with a C11 threads implementation?
There are very few threads.h implementations atm, and looks like no implementation for Windows. threads.h meant to be platform-independent header, so would be nice to add win support in one place, otherwise community will end-up with two different headers :(
Probably most of stuff could be copy-pasted from here https://github.com/tinycthread/tinycthread with saving license note.
So you meant "windows threads", not "windows sockets". Then sure, it would be nice to have C11 threads on windows.
But I don't think this is the place to do that. I have implemented pthreads on windows in the past, and the problem is the win32 API doesn't have a condvar-equivalent construct. This means that a full implementation of C11 threads can't really be a header-only thin wrapper, but rather a full library, like the one you linked. So I suggest using that one instead if you care about windows compatibility.
Still, having said that, if someone cares to contribute a win32 implementation to this "project", and it's clean and well written enough, I will include it.
Ah yes, threads! it was too late in the evening :)
the win32 API doesn't have a condvar-equivalent construct
Mesa has a header-only implementation [1] and it uses the Win32 functions for condition variables.
[1] https://gitlab.freedesktop.org/mesa/mesa/-/blob/22.1/include/c11/threads_win32.h
Nice, I guess they added condition variables to win32 at some point. It was later than the last time I had to deal with win32 programming though. It's only available on windows vista and later.
Nevertheless, that sounds like a good candidate for a windows port of c11threads. So as I said previously, if anyone cares to contribute a windows implementation of all this, I'll be glad to review any pull requests or patches.
Pull request #21 adding support for win32 has been merged.