std::async problems depending on Android version

I'm currently developing a native application that may run on Android devices from API 14. I'm using std::async in my code and so far it did not give any problems with API 16 to API 19 devices, but API 14 and 15 are behaving in a different way:

  • When I'm using std::launch::async, the function is not executing. The wait() call to the returned std::future is blocking permanently.
  • When I don't set the policy, it works. (I presume, it uses deferred).
  • Example:

    std::async(std::launch::async, &foo) <-- never running foo
    std::async(&foo) <-- runs foo
    

    If I flash an API 16 image on the same device, async works as expected.

    I'm using CLang3.4 and the latest toolchain.

    I'm also using gnustl_static.

    I've read similar issues, like: NDK r9c - does not support std::future where the user reports that the LG phone will not start the second task until the first ended.

    Two questions:

  • Why the different behavior depending on the Android version?
  • If I am linking the same gnustd_static library, why the std::async behaves different?
  • 链接地址: http://www.djcxy.com/p/30746.html

    上一篇: 使用std :: async和模板函数

    下一篇: std ::异步问题取决于Android版本