Commit 21770c2
committed
coroutine: allocate coroutine frame in a critical section
Like continuations, coroutines are glue that cannot be allowed
to fail. For example, if cleanup coroutine fails to allocate
and returns an exception future, cleanup will not be done and
the system will enter an undefined state. Better to crash.
This conflicts with test code that tries to inject memory failures
and see how they are handled (file_io_test.cc handle_bad_alloc_test).
The coroutine will throw std::bad_alloc (since we don't define
get_return_object_on_allocation_failure()), and since it's declared
noexcept, will call std::terminate.
To avoid all this, follow future::schedule() and prevent memory
allocation failure injection from interfering with coroutine
frame allocation. In this regard a coroutine frame is just like
a continuation.
This is done by injecting class-specific operator new and operator
delete. Sized deallocation is also defined if supported by the compiler.1 parent d4c7806 commit 21770c2
1 file changed
+20
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| |||
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
54 | 72 | | |
55 | 73 | | |
56 | 74 | | |
57 | | - | |
| 75 | + | |
58 | 76 | | |
59 | 77 | | |
60 | 78 | | |
| |||
106 | 124 | | |
107 | 125 | | |
108 | 126 | | |
109 | | - | |
| 127 | + | |
110 | 128 | | |
111 | 129 | | |
112 | 130 | | |
| |||
0 commit comments