forked from cplusplus/parallelism-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exceptions.html
132 lines (118 loc) · 5.69 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
130
131
132
<cxx-clause id="parallel.exceptions">
<h1>Parallel exceptions</h1>
<cxx-section id="parallel.exceptions.behavior">
<h1>Exception reporting behavior</h1>
<p>
<ins2>During the execution of a standard parallel algorithm, </ins2>
<del2>I</del2><ins2>i</ins2>f temporary memory resources are required <del2>by the algorithm</del2> 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 application of a function
object terminates with 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 <del2>vector_execution_policy</del2><ins2>parallel_vector_execution_policy</ins2></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 terminates with an
<code>exception_list</code> exception. All uncaught exceptions thrown during
the application of user-provided function objects shall be contained in the
<code>exception_list</code>.<pre>
</pre>
<cxx-note>
For example, the number of invocations of the user-provided function object in
<code>for_each</code> is unspecified. When <code>for_each</code> is executed sequentially,
only one exception will be contained in the <code>exception_list</code> object.
</cxx-note><pre>
</pre>
<cxx-note>
These guarantees imply that, unless the algorithm has failed to allocate memory and
terminated with <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 terminate with the <code>std::bad_alloc</code> exception even if one or more
user-provided function objects have terminated with 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.synop">
<h1>Header <code><experimental/exception_list></code> synopsis</h1>
<pre>
namespace std {
namespace experimental {
namespace parallel<ins2>_v1</ins2> {
class exception_list : public exception
{
public:
<del2>
typedef exception_ptr value_type;
typedef const value_type& reference;
typedef const value_type& const_reference;</del2>
typedef <em>implementation-defined</em> const_iterator;
typedef const_iterator iterator;
typedef typename iterator_traits<ins2><const_iterator></ins2>::difference_type difference_type;
<del2>
typedef size_t size_type;</del2>
<del2>size_t</del2><ins2>difference_type</ins2> size() const noexcept;
iterator begin() const noexcept;
iterator end() const noexcept;
<del2>
private:
std::list<exception_ptr> exceptions_; // exposition only
</del2>
};
}
}
}
</pre>
<p>
The class <code>exception_list</code> <del2>is a container</del2> <ins2>owns a sequence</ins2> of <code>exception_ptr</code> objects <ins2>.The</ins2> parallel
algorithms may use <ins2>the <code>exception_list</code></ins2> to communicate uncaught exceptions encountered during parallel execution to the
caller of the algorithm.
</p>
<p>
The type <code>exception_list::const_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>
<del2>exception_list::</del2>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>
<del2>exception_list::</del2>iterator end() const noexcept;
</cxx-signature>
<cxx-returns>
An iterator <del2>which is the past-the-end value for the <code>exception_list</code></del2> <ins2>that is past the end of the owned sequence.</ins2>
</cxx-returns>
</cxx-function>
</cxx-section>
</cxx-clause>