jeudi 22 novembre 2018

std::async is not working in c++11, linux platform

bool tf()
{
    sleep(5000);
    return true;
}

int main()
{
    std::future<bool> bb = std::async(std::launch::async, tf);
    bool b = false;
    while(1)
    {   
        if(b == true) break;

        b = bb.get();
    }   

    return 0;
}

why don't work? I intended to terminate program after 5 seconds. However, the program is freezing.

Aucun commentaire:

Enregistrer un commentaire