forked from cplusplus/parallelism-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exceptions.html
129 lines (110 loc) · 5.38 KB
/
exceptions.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<cxx-clause id="parallel.exceptions">
<h1>Parallel exceptions</h1>
<cxx-section id="parallel.exceptions.behavior">
<h1>Exception reporting behavior</h1>
<p>
During the execution of a standard parallel algorithm,
if temporary memory resources are required and none are available,
the algorithm throws a <code>std::bad_alloc</code> exception.
</p>
<p>
During the execution of a standard parallel algorithm, if the invocation of an element access function
<ins>exits via</ins><del>terminates with</del> an uncaught exception, the behavior of the program is determined by the type of
execution policy used to invoke the algorithm:
<ul>
<li>
If the execution policy object is of type <code>class parallel_vector_execution_policy</code>,
<code>std::terminate</code> shall be called.
</li>
<li>
If the execution policy object is of type <code>sequential_execution_policy</code> or
<code>parallel_execution_policy</code>, the execution of the algorithm <ins>exits via</ins><del>terminates with</del> an
<del><code>exception_list</code></del> exception. <ins>The exception shall be an <code>exception_list</code> containing all</ins><del>All</del> uncaught exceptions thrown during
the invocations of element access functions<ins>, or optionally the uncaught exception if there was only one</ins><del>shall be contained in the
<code>exception_list</code></del>.<pre>
</pre>
<cxx-note>
For example, <del>the number of invocations of the user-provided function object in
<code>for_each</code> is unspecified. W</del><ins>w</ins>hen <code>for_each</code> is executed sequentially,
<ins>if an invocation of the user-provided function object throws an exception, <code>for_each</code> can exit via the uncaught exception, or throw an <code>exception_list</code> containing the original exception.
<del>only one exception will be contained in the <code>exception_list</code> object.</del>
</cxx-note><pre>
</pre>
<cxx-note>
These guarantees imply that, unless the algorithm has failed to allocate memory and
<ins>exits via</ins><del>terminated with</del> <code>std::bad_alloc</code>, all exceptions thrown during the execution of
the algorithm are communicated to the caller. It is unspecified whether an algorithm implementation will "forge ahead" after
encountering and capturing a user exception.
</cxx-note><pre>
</pre>
<cxx-note>
The algorithm may <ins>exit via</ins><del>terminate with</del> the <code>std::bad_alloc</code> exception even if one or more
user-provided function objects have <ins>exited via</ins><del>terminated with</del> an exception. For example, this can happen when an algorithm fails to allocate memory while
creating or adding elements to the <code>exception_list</code> object.
</cxx-note>
</li>
<li>
If the execution policy object is of any other type, the behavior is implementation-defined.
</li>
</ul>
</p>
</cxx-section>
<cxx-section id="parallel.exceptions.synopsis">
<h1>Header <code><experimental/exception_list></code> synopsis</h1>
<pre>
namespace std {
namespace experimental {
namespace parallel {
inline namespace v1 {
class exception_list : public exception
{
public:
typedef <em>unspecified</em> iterator;
size_t size() const noexcept;
iterator begin() const noexcept;
iterator end() const noexcept;
const char* what() const noexcept override;
};
}
}
}
}
</pre>
<p>
The class <code>exception_list</code> owns a sequence of <code>exception_ptr</code> objects. The parallel
algorithms may use the <code>exception_list</code> to communicate uncaught exceptions encountered during parallel execution to the
caller of the algorithm.
</p>
<p>
The type <code>exception_list::iterator</code> shall fulfill the requirements of
<code>ForwardIterator</code>.
</p>
<cxx-function>
<cxx-signature>size_t size() const noexcept;</cxx-signature>
<cxx-returns>
The number of <code>exception_ptr</code> objects contained within the <code>exception_list</code>.
</cxx-returns>
<cxx-complexity>
Constant time.
</cxx-complexity>
</cxx-function>
<cxx-function>
<cxx-signature>iterator begin() const noexcept;</cxx-signature>
<cxx-returns>
An iterator referring to the first <code>exception_ptr</code> object contained within the <code>exception_list</code>.
</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>iterator end() const noexcept;</cxx-signature>
<cxx-returns>
An iterator that is past the end of the owned sequence.
</cxx-returns>
</cxx-function>
<cxx-function>
<cxx-signature>const char* what() const noexcept override;</cxx-signature>
<cxx-returns>
An implementation-defined NTBS.
</cxx-returns>
</cxx-function>
</cxx-section>
</cxx-clause>