tbb::movable_exception< ExceptionData > Class Template Reference

Template that can be used to implement exception that transfers arbitrary ExceptionData to the root thread. More...

`#include <tbb_exception.h>`

Inheritance diagram for tbb::movable_exception< ExceptionData >:
Collaboration diagram for tbb::movable_exception< ExceptionData >:

## Public Member Functions

| movable_exception (const ExceptionData &data_)
| movable_exception (const movable_exception &src) throw ()
| ~movable_exception () throw ()
const movable_exception & | operator= (const movable_exception &src)
ExceptionData & | data () throw ()
const ExceptionData & | data () const throw ()
const char * | name () const __TBB_override throw ()
| Returns RTTI name of the originally intercepted exception. More...
const char * | what () const __TBB_override throw ()
| Returns the result of originally intercepted exception's what() method. More...
movable_exception * | move () __TBB_override throw ()
| Creates and returns pointer to the deep copy of this exception object. More...
void | destroy () __TBB_override throw ()
| Destroys objects created by the move() method. More...
void | throw_self () __TBB_override
| Throws this exception object. More...
Public Member Functions inherited from tbb::tbb_exception
void | operator delete (void *p)

## Protected Attributes

ExceptionData | my_exception_data
| User data. More...

## Private Types

typedef movable_exception< ExceptionData > | self_type

## Private Attributes

bool | my_dynamic
| Flag specifying whether this object has been dynamically allocated (by the move method) More...
const char * | my_exception_name
| RTTI name of this class. More...

## Detailed Description

### template<typename ExceptionData>
class tbb::movable_exception< ExceptionData >

Template that can be used to implement exception that transfers arbitrary ExceptionData to the root thread.

Code using TBB can instantiate this template with an arbitrary ExceptionData type and throw this exception object. Such exceptions are intercepted by the TBB scheduler and delivered to the root thread ().

See also
  tbb::tbb_exception

Definition at line 247 of file tbb_exception.h.

## Member Typedef Documentation

## self_type

template<typename ExceptionData >

typedef movable_exception<ExceptionData> tbb::movable_exception< ExceptionData >::self_type

private

Definition at line 249 of file tbb_exception.h.

## Constructor & Destructor Documentation

## movable_exception() [1/2]

template<typename ExceptionData >

tbb::movable_exception< ExceptionData >::movable_exception | ( | const ExceptionData & | data_ | ) |

inline

Definition at line 252 of file tbb_exception.h.

: my_exception_data(data_)
, my_dynamic(false)
, my_exception_name(
#if TBB_USE_EXCEPTIONS
typeid(self_type).name()
#else /* !TBB_USE_EXCEPTIONS */
"movable_exception"
#endif /* !TBB_USE_EXCEPTIONS */
)
{}
TBB_USE_EXCEPTIONS
#define TBB_USE_EXCEPTIONS
Definition: tbb_config.h:464
tbb::movable_exception::my_dynamic
bool my_dynamic
Flag specifying whether this object has been dynamically allocated (by the move method)
Definition: tbb_exception.h:312
tbb::movable_exception::my_exception_name
const char * my_exception_name
RTTI name of this class.
Definition: tbb_exception.h:316
tbb::movable_exception::self_type
movable_exception< ExceptionData > self_type
Definition: tbb_exception.h:249
tbb::movable_exception::my_exception_data
ExceptionData my_exception_data
User data.
Definition: tbb_exception.h:308
tbb::movable_exception::name
const char * name() const __TBB_override
Returns RTTI name of the originally intercepted exception.
Definition: tbb_exception.h:285

## movable_exception() [2/2]

template<typename ExceptionData >

tbb::movable_exception< ExceptionData >::movable_exception | ( | const movable_exception< ExceptionData > & | src | ) |
throw | ( |
| ) |  |

inline

Definition at line 264 of file tbb_exception.h.

: tbb_exception(src)
, my_exception_data(src.my_exception_data)
, my_dynamic(false)
, my_exception_name(src.my_exception_name)
{}

## ~movable_exception()

template<typename ExceptionData >

tbb::movable_exception< ExceptionData >::~movable_exception | ( |  | ) |
throw | ( |
| ) |  |

inline

Definition at line 271 of file tbb_exception.h.

{}

## Member Function Documentation

## data() [1/2]

template<typename ExceptionData >

ExceptionData& tbb::movable_exception< ExceptionData >::data | ( |  | ) |
throw | ( |
| ) |  |

inline

Definition at line 281 of file tbb_exception.h.

{ return my_exception_data; }

## data() [2/2]

template<typename ExceptionData >

const ExceptionData& tbb::movable_exception< ExceptionData >::data | ( |  | ) | const
throw | ( |
| ) |  |

inline

Definition at line 283 of file tbb_exception.h.

{ return my_exception_data; }

## destroy()

template<typename ExceptionData >

void tbb::movable_exception< ExceptionData >::destroy | ( |  | ) |
throw | ( |
| ) |  |

inline virtual

Destroys objects created by the move() method.

Frees memory and calls destructor for this exception object. Can and must be used only on objects created by the move method.

Implements tbb::tbb_exception.

Definition at line 297 of file tbb_exception.h.

{
__TBB_ASSERT ( my_dynamic, "Method destroy can be called only on dynamically allocated movable_exceptions" );
if ( my_dynamic ) {
this->~movable_exception();
internal::deallocate_via_handler_v3(this);
}
}
__TBB_ASSERT
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
Definition: tbb_stddef.h:165
tbb::internal::deallocate_via_handler_v3
void __TBB_EXPORTED_FUNC deallocate_via_handler_v3(void *p)
Deallocates memory using FreeHandler.
Definition: cache_aligned_allocator.cpp:232
tbb::movable_exception::~movable_exception
~movable_exception()
Definition: tbb_exception.h:271

References __TBB_ASSERT, and tbb::internal::deallocate_via_handler_v3().

Here is the call graph for this function:

## move()

template<typename ExceptionData >

movable_exception* tbb::movable_exception< ExceptionData >::move | ( |  | ) |
throw | ( |
| ) |  |

inline virtual

Creates and returns pointer to the deep copy of this exception object.

Move semantics is allowed.

Implements tbb::tbb_exception.

Definition at line 289 of file tbb_exception.h.

{
void* e = internal::allocate_via_handler_v3(sizeof(movable_exception));
if ( e ) {
::new (e) movable_exception(*this);
((movable_exception*)e)->my_dynamic = true;
}
return (movable_exception*)e;
}
tbb::internal::allocate_via_handler_v3
void *__TBB_EXPORTED_FUNC allocate_via_handler_v3(size_t n)
Allocates memory using MallocHandler.
Definition: cache_aligned_allocator.cpp:224
tbb::movable_exception::movable_exception
movable_exception(const ExceptionData &data_)
Definition: tbb_exception.h:252

References tbb::internal::allocate_via_handler_v3().

Here is the call graph for this function:

## name()

template<typename ExceptionData >

const char* tbb::movable_exception< ExceptionData >::name | ( |  | ) | const
throw | ( |
| ) |  |

inline virtual

Returns RTTI name of the originally intercepted exception.

Implements tbb::tbb_exception.

Definition at line 285 of file tbb_exception.h.

{ return my_exception_name; }

## operator=()

template<typename ExceptionData >

const movable_exception& tbb::movable_exception< ExceptionData >::operator= | ( | const movable_exception< ExceptionData > & | src | ) |

inline

Definition at line 273 of file tbb_exception.h.

{
if ( this != &src ) {
my_exception_data = src.my_exception_data;
my_exception_name = src.my_exception_name;
}
return *this;
}

References tbb::movable_exception< ExceptionData >::my_exception_data, and tbb::movable_exception< ExceptionData >::my_exception_name.

## throw_self()

template<typename ExceptionData >

void tbb::movable_exception< ExceptionData >::throw_self | ( |  | ) |

inline virtual

Throws this exception object.

Make sure that if you have several levels of derivation from this interface you implement or override this method on the most derived level. The implementation is as simple as "throw *this;". Failure to do this will result in exception of a base class type being thrown.

Implements tbb::tbb_exception.

Definition at line 304 of file tbb_exception.h.

{ __TBB_THROW( *this ); }
__TBB_THROW
#define __TBB_THROW(e)
Definition: tbb_stddef.h:285

References __TBB_THROW.

## what()

template<typename ExceptionData >

const char* tbb::movable_exception< ExceptionData >::what | ( |  | ) | const
throw | ( |
| ) |  |

inline virtual

Returns the result of originally intercepted exception's what() method.

Implements tbb::tbb_exception.

Definition at line 287 of file tbb_exception.h.

{ return "tbb::movable_exception"; }

## Member Data Documentation

## my_dynamic

template<typename ExceptionData >

bool tbb::movable_exception< ExceptionData >::my_dynamic

private

Flag specifying whether this object has been dynamically allocated (by the move method)

Definition at line 312 of file tbb_exception.h.

## my_exception_data

template<typename ExceptionData >

ExceptionData tbb::movable_exception< ExceptionData >::my_exception_data

protected

User data.

Definition at line 308 of file tbb_exception.h.

Referenced by tbb::movable_exception< ExceptionData >::operator=().

## my_exception_name

template<typename ExceptionData >

const char* tbb::movable_exception< ExceptionData >::my_exception_name

private

RTTI name of this class.

We rely on the fact that RTTI names are static string constants.

Definition at line 316 of file tbb_exception.h.

Referenced by tbb::movable_exception< ExceptionData >::operator=().

The documentation for this class was generated from the following file:

- tbb_exception.h

Copyright © 2005-2020 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.