1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: no-threads
14 // template <class F, class... Args>
15 // future<typename result_of<F(Args...)>::type>
16 // async(F&& f, Args&&... args);
18 // template <class F, class... Args>
19 // future<typename result_of<F(Args...)>::type>
20 // async(launch policy, F&& f, Args&&... args);
22 // This test is designed to cause and allow TSAN to detect the race condition
23 // reported in PR23293: https://llvm.org/PR23293
31 #include "test_macros.h"
34 typedef std::chrono::milliseconds ms
;
35 std::this_thread::sleep_for(ms(200));
48 std::future
<int> f
= std::async(f_async
);
49 int const result
= f
.get();
53 std::future
<int> f
= std::async(std::launch::async
, f_async
);
54 int const result
= f
.get();
59 std::future
<int> f
= std::async(std::launch::deferred
, f_deferred
);
61 int const result
= f
.get();
67 int main(int, char**) {
68 for (int i
=0; i
< 25; ++i
) test_each();