Search code examples
multithreadingc++11cygwincondition-variable

notify_all_at_thread_exit doesn't exist in Cygwin GCC


When I try to build the following simple test program in 32-bit Cygwin with GCC version 4.9.2, I get an error saying:

error: ‘notify_all_at_thread_exit’ is not a member of ‘std’

This makes me think that this specific method hasn't been ported to Cygwin. Does anyone know if I am either doing something wrong or if I can determine that this indeed is missing from Cygwin?

Build line:

 /usr/bin/c++.exe -std=gnu++11 -o NotifyAllAtThreadExitTest.cc.o -c NotifyAllAtThreadExitTest.cc

Code snippet:

#include <mutex>
#include <thread>
#include <condition_variable>

std::mutex m;
std::condition_variable cv;

bool ready = false;

void thread_func()
{
    std::unique_lock<std::mutex> lk(m);
    ready = true;
    std::notify_all_at_thread_exit(cv, std::move(lk));
}

int test()
{
    std::thread t(thread_func);
    t.detach();

    std::unique_lock<std::mutex> lk(m);
    while(!ready) {
        cv.wait(lk);
    }
}

Solution

  • In the 4.9 release series, libstdc++ does not implement std::notify_all_at_thread_exit. It will be present in the gcc 5.0 release, in fact it was just added in revision 218255 on 2014-12-02.