lhmouse/mcfgthread

pthread and standalone c11 thread support

Closed this issue · 1 comments

If I understand correctly, mcfgthread is a gthread implementation and a c11 thread implementation, but not a pthread implementation.

My use case is to build mpv via llvm mingw toolchain, and it looks like mcfgthread has recently refined llvm support, but libc++ already supports win32 thread, so mcfgthread doesn't seem to make much sense here.

but llvm-mingw still doesn't support c11 thread and is highly dependent on winpthreads to support pthread, so I'd like to be able to support c11 thread via mcfgthread and replace winpthreads to improve language standard compatibility and performance.

In a nutshell, my use case is as follows:
Using libc++ win32 thread implementation to support c++11 thread
Using mcfgthread to support c11 thread
Using mcfgthread instead of winpthreads to support high performance pthread

Is this a meaningful use case please? Thanks.

If I understand correctly, mcfgthread is a gthread implementation and a c11 thread implementation, but not a pthread implementation.

Mostly. The C11 standard require that library functions have external linkage, which requires a little more work.

My use case is to build mpv via llvm mingw toolchain, and it looks like mcfgthread has recently refined llvm support, but libc++ already supports win32 thread, so mcfgthread doesn't seem to make much sense here.

but llvm-mingw still doesn't support c11 thread and is highly dependent on winpthreads to support pthread, so I'd like to be able to support c11 thread via mcfgthread and replace winpthreads to improve language standard compatibility and performance.

The current status is that mcfgthread can be built with Clang and used as an ordinary library. There is no mcf thread model in LLVM, unlike in GCC.

In a nutshell, my use case is as follows: Using libc++ win32 thread implementation to support c++11 thread Using mcfgthread to support c11 thread Using mcfgthread instead of winpthreads to support high performance pthread

Is this a meaningful use case please? Thanks.

You do not have to use the libc++ thread; instead, there is a C++11-ish wrapper header:

#include <mcfgthread/cxx11.hpp>
using ::_MCF::thread;
using ::_MCF::mutex;
// ...

Some infrastructures of the language itself (and not of the standard library), such as thread_local and thread-safe initialization of local static objects, are still implemented in libc++, but mostly they are orthogonal and harmless.