Closed adeelbaba closed 7 years ago
GCC's libstdc++ doesn't have a Windows-native implementation of the multithreading headers, and I'm uninterested in building any Win32/Posix wrappers. I recommend using Boost.Thread with -DBOOST_THREAD_VERSION=4
to request Standard-conformant behavior.
I'll reactivate this because it's an upstream issue that's causing me headaches (e.g. in Boost.Fiber and glbinding).
mingw-w64's website says "Winpthreads has been merged into the main tarball as of 3.1.0." I may reluctantly consider figuring out how to build this.
Although the underlying problem remains, I believe I can enable winpthreads and OpenMP in distro 15.2.
I just downloaded the latest distribution from https://nuwen.net/mingw.html
But when I compile a simple program that uses std::mutex I get compile time errors.
The simple code I used is as follows:
include
include
include
include
include
include
std::map<std::string, std::string> g_pages; std::mutex g_pages_mutex;
void save_page(const std::string &url) { // simulate a long page fetch std::this_thread::sleep_for(std::chrono::seconds(2)); std::string result = "fake content";
}
int main() { std::thread t1(save_page, "http://foo"); std::thread t2(save_page, "http://bar"); t1.join(); t2.join();
}
Any help would be much appreciated.