File indexing completed on 2025-01-18 10:13:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef __TBB_exception_H
0018 #define __TBB_exception_H
0019
0020 #define __TBB_tbb_exception_H_include_area
0021 #include "internal/_warning_suppress_enable_notice.h"
0022
0023 #include "tbb_stddef.h"
0024 #include <exception>
0025 #include <new> // required for bad_alloc definition, operators new
0026 #include <string> // required to construct std exception classes
0027
0028 namespace tbb {
0029
0030
0031 class bad_last_alloc : public std::bad_alloc {
0032 public:
0033 const char* what() const throw() __TBB_override;
0034 #if __TBB_DEFAULT_DTOR_THROW_SPEC_BROKEN
0035 ~bad_last_alloc() throw() __TBB_override {}
0036 #endif
0037 };
0038
0039
0040 class __TBB_DEPRECATED improper_lock : public std::exception {
0041 public:
0042 const char* what() const throw() __TBB_override;
0043 };
0044
0045
0046 class user_abort : public std::exception {
0047 public:
0048 const char* what() const throw() __TBB_override;
0049 };
0050
0051
0052 class missing_wait : public std::exception {
0053 public:
0054 const char* what() const throw() __TBB_override;
0055 };
0056
0057
0058 class invalid_multiple_scheduling : public std::exception {
0059 public:
0060 const char* what() const throw() __TBB_override;
0061 };
0062
0063 namespace internal {
0064
0065 void __TBB_EXPORTED_FUNC throw_bad_last_alloc_exception_v4();
0066
0067 enum exception_id {
0068 eid_bad_alloc = 1,
0069 eid_bad_last_alloc,
0070 eid_nonpositive_step,
0071 eid_out_of_range,
0072 eid_segment_range_error,
0073 eid_index_range_error,
0074 eid_missing_wait,
0075 eid_invalid_multiple_scheduling,
0076 eid_improper_lock,
0077 eid_possible_deadlock,
0078 eid_operation_not_permitted,
0079 eid_condvar_wait_failed,
0080 eid_invalid_load_factor,
0081 eid_reserved,
0082 eid_invalid_swap,
0083 eid_reservation_length_error,
0084 eid_invalid_key,
0085 eid_user_abort,
0086 eid_reserved1,
0087 #if __TBB_SUPPORTS_WORKERS_WAITING_IN_TERMINATE
0088
0089
0090 eid_blocking_thread_join_impossible = eid_reserved1,
0091 #endif
0092 eid_bad_tagged_msg_cast,
0093
0094
0095
0096 eid_max
0097 };
0098
0099
0100
0101
0102 void __TBB_EXPORTED_FUNC throw_exception_v4 ( exception_id );
0103
0104
0105 inline void throw_exception ( exception_id eid ) { throw_exception_v4(eid); }
0106
0107 }
0108 }
0109
0110 #if __TBB_TASK_GROUP_CONTEXT
0111 #include "tbb_allocator.h"
0112 #include <typeinfo> //for typeid
0113
0114 namespace tbb {
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137 class __TBB_DEPRECATED tbb_exception : public std::exception
0138 {
0139
0140
0141
0142 void* operator new ( size_t );
0143
0144 public:
0145 #if __clang__
0146
0147
0148
0149
0150 ~tbb_exception() throw() { ; }
0151 #endif
0152
0153
0154
0155 virtual tbb_exception* move() throw() = 0;
0156
0157
0158
0159
0160 virtual void destroy() throw() = 0;
0161
0162
0163
0164
0165
0166
0167 virtual void throw_self() = 0;
0168
0169
0170 virtual const char* name() const throw() = 0;
0171
0172
0173 virtual const char* what() const throw() __TBB_override = 0;
0174
0175
0176
0177
0178
0179
0180
0181 void operator delete ( void* p ) {
0182 internal::deallocate_via_handler_v3(p);
0183 }
0184 };
0185
0186
0187
0188
0189
0190
0191 class __TBB_DEPRECATED_IN_VERBOSE_MODE captured_exception : public tbb_exception
0192 {
0193 public:
0194 captured_exception( const captured_exception& src )
0195 : tbb_exception(src), my_dynamic(false)
0196 {
0197 set(src.my_exception_name, src.my_exception_info);
0198 }
0199
0200 captured_exception( const char* name_, const char* info )
0201 : my_dynamic(false)
0202 {
0203 set(name_, info);
0204 }
0205
0206 __TBB_EXPORTED_METHOD ~captured_exception() throw();
0207
0208 captured_exception& operator= ( const captured_exception& src ) {
0209 if ( this != &src ) {
0210 clear();
0211 set(src.my_exception_name, src.my_exception_info);
0212 }
0213 return *this;
0214 }
0215
0216 captured_exception* __TBB_EXPORTED_METHOD move() throw() __TBB_override;
0217
0218 void __TBB_EXPORTED_METHOD destroy() throw() __TBB_override;
0219
0220 void throw_self() __TBB_override { __TBB_THROW(*this); }
0221
0222 const char* __TBB_EXPORTED_METHOD name() const throw() __TBB_override;
0223
0224 const char* __TBB_EXPORTED_METHOD what() const throw() __TBB_override;
0225
0226 void __TBB_EXPORTED_METHOD set( const char* name, const char* info ) throw();
0227 void __TBB_EXPORTED_METHOD clear() throw();
0228
0229 private:
0230
0231 captured_exception() : my_dynamic(), my_exception_name(), my_exception_info() {}
0232
0233
0234 static captured_exception* allocate( const char* name, const char* info );
0235
0236 bool my_dynamic;
0237 const char* my_exception_name;
0238 const char* my_exception_info;
0239 };
0240
0241
0242
0243
0244
0245
0246 template<typename ExceptionData>
0247 class __TBB_DEPRECATED movable_exception : public tbb_exception
0248 {
0249 typedef movable_exception<ExceptionData> self_type;
0250
0251 public:
0252 movable_exception( const ExceptionData& data_ )
0253 : my_exception_data(data_)
0254 , my_dynamic(false)
0255 , my_exception_name(
0256 #if TBB_USE_EXCEPTIONS
0257 typeid(self_type).name()
0258 #else
0259 "movable_exception"
0260 #endif
0261 )
0262 {}
0263
0264 movable_exception( const movable_exception& src ) throw ()
0265 : tbb_exception(src)
0266 , my_exception_data(src.my_exception_data)
0267 , my_dynamic(false)
0268 , my_exception_name(src.my_exception_name)
0269 {}
0270
0271 ~movable_exception() throw() {}
0272
0273 const movable_exception& operator= ( const movable_exception& src ) {
0274 if ( this != &src ) {
0275 my_exception_data = src.my_exception_data;
0276 my_exception_name = src.my_exception_name;
0277 }
0278 return *this;
0279 }
0280
0281 ExceptionData& data() throw() { return my_exception_data; }
0282
0283 const ExceptionData& data() const throw() { return my_exception_data; }
0284
0285 const char* name() const throw() __TBB_override { return my_exception_name; }
0286
0287 const char* what() const throw() __TBB_override { return "tbb::movable_exception"; }
0288
0289 movable_exception* move() throw() __TBB_override {
0290 void* e = internal::allocate_via_handler_v3(sizeof(movable_exception));
0291 if ( e ) {
0292 ::new (e) movable_exception(*this);
0293 ((movable_exception*)e)->my_dynamic = true;
0294 }
0295 return (movable_exception*)e;
0296 }
0297 void destroy() throw() __TBB_override {
0298 __TBB_ASSERT ( my_dynamic, "Method destroy can be called only on dynamically allocated movable_exceptions" );
0299 if ( my_dynamic ) {
0300 this->~movable_exception();
0301 internal::deallocate_via_handler_v3(this);
0302 }
0303 }
0304 void throw_self() __TBB_override { __TBB_THROW( *this ); }
0305
0306 protected:
0307
0308 ExceptionData my_exception_data;
0309
0310 private:
0311
0312 bool my_dynamic;
0313
0314
0315
0316 const char* my_exception_name;
0317 };
0318
0319 #if !TBB_USE_CAPTURED_EXCEPTION
0320 namespace internal {
0321
0322
0323
0324
0325 class tbb_exception_ptr {
0326 std::exception_ptr my_ptr;
0327
0328 public:
0329 static tbb_exception_ptr* allocate();
0330 static tbb_exception_ptr* allocate( const tbb_exception& tag );
0331
0332 static tbb_exception_ptr* allocate( captured_exception& src );
0333
0334
0335
0336 void destroy() throw();
0337
0338
0339 void throw_self() { std::rethrow_exception(my_ptr); }
0340
0341 private:
0342 tbb_exception_ptr( const std::exception_ptr& src ) : my_ptr(src) {}
0343 tbb_exception_ptr( const captured_exception& src ) :
0344 #if __TBB_MAKE_EXCEPTION_PTR_PRESENT
0345 my_ptr(std::make_exception_ptr(src))
0346 #else
0347 my_ptr(std::copy_exception(src))
0348 #endif
0349 {}
0350 };
0351
0352 }
0353 #endif
0354
0355 }
0356
0357 #endif
0358
0359 #include "internal/_warning_suppress_disable_notice.h"
0360 #undef __TBB_tbb_exception_H_include_area
0361
0362 #endif