• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

LICENSEH A D15-Oct-20211.3 KiB2519

README.mdH A D15-Oct-20212.7 KiB4231

mingw.condition_variable.hH A D15-Oct-202119.1 KiB556460

mingw.invoke.hH A D15-Oct-20213.4 KiB11086

mingw.mutex.hH A D15-Oct-202115.4 KiB485410

mingw.shared_mutex.hH A D15-Oct-202114.5 KiB497374

mingw.thread.hH A D15-Oct-202110.9 KiB334264

README.md

1mingw-std-threads
2=================
3
4Implementation of standard C++11 threading classes, which are currently still missing on MinGW GCC.
5
6Target Windows version
7----------------------
8This implementation should work with Windows XP (regardless of service pack), or newer.
9The library automatically detects the version of Windows that is being targeted (at compile time), and selects an implementation that takes advantage of available Windows features.
10In MinGW GCC, the target Windows version may optionally be selected by the command-line option `-D _WIN32_WINNT=...`.
11Use `0x0600` for Windows Vista, or `0x0601` for Windows 7.
12See "[Modifying `WINVER` and `_WIN32_WINNT`](https://docs.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt)" for more details.
13
14Usage
15-----
16
17This is a header-only library. To use, just include the corresponding `mingw.xxx.h file`, where `xxx` would be the name of the standard header that you would normally include.
18
19For example, `#include "mingw.thread.h"` replaces `#include <thread>`.
20
21Compatibility
22-------------
23
24This code has been tested to work with MinGW-w64 5.3.0, but should work with any other MinGW version that has the `std` threading classes missing, has C++11 support for lambda functions, variadic templates, and has working mutex helper classes in `<mutex>`.
25
26Switching from the win32-pthread based implementation
27-----------------------------------------------------
28It seems that recent versions of MinGW-w64 include a Win32 port of pthreads, and have the `std::thread`, `std::mutex`, etc. classes implemented and working based on that compatibility
29layer.
30That is a somewhat heavier implementation, as it relies on an abstraction layer, so you may still want to use this implementation for efficiency purposes.
31Unfortunately you can't use this library standalone and independent of the system `<mutex>` headers, as it relies on those headers for `std::unique_lock` and other non-trivial utility classes.
32In that case you will need to edit the `c++-config.h` file of your MinGW setup and comment out the definition of _GLIBCXX_HAS_GTHREADS.
33This will cause the system headers not to define the actual `thread`, `mutex`, etc. classes, but still define the necessary utility classes.
34
35Why MinGW has no threading classes
36----------------------------------
37It seems that for cross-platform threading implementation, the GCC standard library relies on the gthreads/pthreads library.
38If this library is not available, as is the case with MinGW, the classes `std::thread`, `std::mutex`, `std::condition_variable` are not defined.
39However, various usable helper classes are still defined in the system headers.
40Hence, this implementation does not re-define them, and instead includes those headers.
41
42