File tree Expand file tree Collapse file tree 2 files changed +55
-2
lines changed
test/std/thread/futures/futures.async Expand file tree Collapse file tree 2 files changed +55
-2
lines changed Original file line number Diff line number Diff line change @@ -865,7 +865,8 @@ void __async_assoc_state<_Rp, _Fp>::__execute() {
865
865
866
866
template <class _Rp , class _Fp >
867
867
void __async_assoc_state<_Rp, _Fp>::__on_zero_shared () _NOEXCEPT {
868
- this ->wait ();
868
+ if (base::__state_ & base::__constructed)
869
+ this ->wait ();
869
870
base::__on_zero_shared ();
870
871
}
871
872
@@ -902,7 +903,8 @@ void __async_assoc_state<void, _Fp>::__execute() {
902
903
903
904
template <class _Fp >
904
905
void __async_assoc_state<void , _Fp>::__on_zero_shared () _NOEXCEPT {
905
- this ->wait ();
906
+ if (base::__state_ & base::__constructed)
907
+ this ->wait ();
906
908
base::__on_zero_shared ();
907
909
}
908
910
Original file line number Diff line number Diff line change
1
+ // ===----------------------------------------------------------------------===//
2
+ //
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
6
+ //
7
+ // ===----------------------------------------------------------------------===//
8
+ //
9
+ // UNSUPPORTED: no-threads, no-exceptions
10
+
11
+ // UNSUPPORTED: c++03
12
+
13
+ // There is no way to limit the number of threads on windows
14
+ // UNSUPPORTED: msvc
15
+
16
+ // AIX doesn't seem to complain if the thread limit is reached.
17
+ // XFAIL: target={{.+}}-aix{{.*}}
18
+
19
+ #include < cassert>
20
+ #include < future>
21
+ #include < system_error>
22
+
23
+ #if __has_include(<sys/resource.h>)
24
+ # include < sys/resource.h>
25
+ # ifdef RLIMIT_NPROC
26
+ void force_thread_creation_failure () {
27
+ rlimit lim = {1 , 1 };
28
+ setrlimit (RLIMIT_NPROC, &lim);
29
+ }
30
+ # else
31
+ # error "No known way to force only one thread being available"
32
+ # endif
33
+ #else
34
+ # error "No known way to force only one thread being available"
35
+ #endif
36
+
37
+ int main () {
38
+ force_thread_creation_failure ();
39
+
40
+ try {
41
+ auto fut = std::async (std::launch::async, [] { return 1 ; });
42
+ assert (false );
43
+ } catch (const std::system_error&) {
44
+ }
45
+
46
+ try {
47
+ auto fut = std::async (std::launch::async, [] { return ; });
48
+ assert (false );
49
+ } catch (const std::system_error&) {
50
+ }
51
+ }
You can’t perform that action at this time.
0 commit comments