1 | /* |
2 | Copyright (c) 2005-2021 Intel Corporation |
3 | |
4 | Licensed under the Apache License, Version 2.0 (the "License"); |
5 | you may not use this file except in compliance with the License. |
6 | You may obtain a copy of the License at |
7 | |
8 | http://www.apache.org/licenses/LICENSE-2.0 |
9 | |
10 | Unless required by applicable law or agreed to in writing, software |
11 | distributed under the License is distributed on an "AS IS" BASIS, |
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | See the License for the specific language governing permissions and |
14 | limitations under the License. |
15 | */ |
16 | |
17 | #ifndef __TBB__exception_H |
18 | #define __TBB__exception_H |
19 | |
20 | #include "_config.h" |
21 | |
22 | #include <new> // std::bad_alloc |
23 | #include <exception> // std::exception |
24 | #if __TBB_SUPPORTS_WORKERS_WAITING_IN_TERMINATE |
25 | #include <stdexcept> // std::runtime_error |
26 | #endif |
27 | |
28 | namespace tbb { |
29 | namespace detail { |
30 | inline namespace d0 { |
31 | enum class exception_id { |
32 | bad_alloc = 1, |
33 | bad_last_alloc, |
34 | user_abort, |
35 | nonpositive_step, |
36 | out_of_range, |
37 | reservation_length_error, |
38 | missing_wait, |
39 | invalid_load_factor, |
40 | invalid_key, |
41 | bad_tagged_msg_cast, |
42 | unsafe_wait, |
43 | #if __TBB_PREVIEW_TASK_GROUP_EXTENSIONS |
44 | bad_task_handle, |
45 | bad_task_handle_wrong_task_group, |
46 | #endif // __TBB_PREVIEW_TASK_GROUP_EXTENSIONS |
47 | last_entry |
48 | }; |
49 | } // namespace d0 |
50 | |
51 | #if _MSC_VER |
52 | #pragma warning(disable: 4275) |
53 | #endif |
54 | |
55 | namespace r1 { |
56 | //! Exception for concurrent containers |
57 | class TBB_EXPORT bad_last_alloc : public std::bad_alloc { |
58 | public: |
59 | const char* __TBB_EXPORTED_METHOD what() const noexcept(true) override; |
60 | }; |
61 | |
62 | //! Exception for user-initiated abort |
63 | class TBB_EXPORT user_abort : public std::exception { |
64 | public: |
65 | const char* __TBB_EXPORTED_METHOD what() const noexcept(true) override; |
66 | }; |
67 | |
68 | //! Exception for missing wait on structured_task_group |
69 | class TBB_EXPORT missing_wait : public std::exception { |
70 | public: |
71 | const char* __TBB_EXPORTED_METHOD what() const noexcept(true) override; |
72 | }; |
73 | |
74 | #if __TBB_SUPPORTS_WORKERS_WAITING_IN_TERMINATE |
75 | //! Exception for impossible finalization of task_sheduler_handle |
76 | class unsafe_wait : public std::runtime_error { |
77 | public: |
78 | unsafe_wait(const char* msg) : std::runtime_error(msg) {} |
79 | }; |
80 | #endif // __TBB_SUPPORTS_WORKERS_WAITING_IN_TERMINATE |
81 | |
82 | //! Gathers all throw operators in one place. |
83 | /** Its purpose is to minimize code bloat that can be caused by throw operators |
84 | scattered in multiple places, especially in templates. **/ |
85 | TBB_EXPORT void __TBB_EXPORTED_FUNC throw_exception ( exception_id ); |
86 | } // namespace r1 |
87 | |
88 | inline namespace d0 { |
89 | using r1::throw_exception; |
90 | } // namespace d0 |
91 | |
92 | } // namespace detail |
93 | } // namespace tbb |
94 | |
95 | #endif // __TBB__exception_H |
96 | |
97 | |