tbb::interface6::runtime_loader Class Reference

Load TBB at runtime. More...

`#include <runtime_loader.h>`

Inheritance diagram for tbb::interface6::runtime_loader:
Collaboration diagram for tbb::interface6::runtime_loader:

## Public Types

enum | error_mode { em_status, em_throw, em_abort }
| Error mode constants. More...
enum | error_code { ec_ok, ec_bad_call, ec_bad_arg, ec_bad_lib, ec_bad_ver, ec_no_lib }
| Error codes. More...

## Public Member Functions

| runtime_loader (error_mode mode=em_abort)
| Initialize object but do not load TBB. More...
| runtime_loader (char const *path[], int min_ver=TBB_INTERFACE_VERSION, int max_ver=INT_MAX, error_mode mode=em_abort)
| Initialize object and load TBB. More...
| ~runtime_loader ()
| Destroy object. More...
error_code | load (char const *path[], int min_ver=TBB_INTERFACE_VERSION, int max_ver=INT_MAX)
| Load TBB. More...
error_code | status ()
| Report status. More...

## Private Attributes

const error_mode | my_mode
error_code | my_status
bool | my_loaded

## Additional Inherited Members

Private Member Functions inherited from tbb::internal::no_copy
| no_copy (const no_copy &)=delete
| no_copy ()=default

## Detailed Description

Load TBB at runtime.

Usage:

In source code:

#include "tbb/runtime_loader.h"
char const * path[] = { "<install dir>/lib/ia32", NULL };
tbb::runtime_loader loader( path );
// Now use TBB.

Link with `tbbproxy.lib` (or `libtbbproxy.a`) instead of `tbb.lib` (`libtbb.dylib`, `libtbb.so`).

TBB library will be loaded at runtime from `` <install dir>="">/lib/ia32 directory.

Attention:

All `runtime_loader` objects (in the same module, i.e. exe or dll) share some global state. The most noticeable piece of global state is loaded TBB library. There are some implications:

    -   Only one TBB library can be loaded per module.

    -   If one object has already loaded TBB library, another object will not load TBB.
        If the loaded TBB library is suitable for the second object, both will use TBB
        cooperatively, otherwise the second object will report an error.

    -   \c runtime_loader objects will not work (correctly) in parallel due to absence of
        synchronization.

Definition at line 95 of file runtime_loader.h.

## Member Enumeration Documentation

## error_code

enum tbb::interface6::runtime_loader::error_code

Error codes.

Enumerator
ec_ok | No errors.
ec_bad_call | Invalid function call (e. g. load() called when TBB is already loaded).
ec_bad_arg | Invalid argument passed.
ec_bad_lib | Invalid library found (e. g. `TBB_runtime_version` symbol not found).
ec_bad_ver | TBB found but version is not suitable.
ec_no_lib | No suitable TBB library found.

Definition at line 107 of file runtime_loader.h.

{
ec_ok,
ec_bad_call,
ec_bad_arg,
ec_bad_lib,
ec_bad_ver,
ec_no_lib
}; // error_code

## error_mode

enum tbb::interface6::runtime_loader::error_mode

Error mode constants.

Enumerator
em_status | Save status of operation and continue.
em_throw | Throw an exception of tbb::runtime_loader::error_code type.
em_abort | Print message to `stderr` and call `abort()`.

Definition at line 100 of file runtime_loader.h.

{
em_status,
em_throw,
em_abort
}; // error_mode

## Constructor & Destructor Documentation

## runtime_loader() [1/2]

tbb::interface6::runtime_loader::runtime_loader | ( | error_mode | mode = `em_abort` | ) |

Initialize object but do not load TBB.

## runtime_loader() [2/2]

tbb::interface6::runtime_loader::runtime_loader | ( | char const * | path[],
|  | int | min_ver = `TBB_INTERFACE_VERSION`,
|  | int | max_ver = `INT_MAX`,
|  | error_mode | mode = `em_abort`
| ) |  |

Initialize object and load TBB.

See load() for details.

If error mode is `em_status`, call status() to check whether TBB was loaded or not.

Parameters

  path | List of directories to search TBB in.
  min_ver | Minimal suitable version of TBB.
  max_ver | Maximal suitable version of TBB.
  mode | Error mode for this object.

## ~runtime_loader()

tbb::interface6::runtime_loader::~runtime_loader | ( |  | ) |

Destroy object.

## Member Function Documentation

## load()

error_code tbb::interface6::runtime_loader::load | ( | char const * | path[],
|  | int | min_ver = `TBB_INTERFACE_VERSION`,
|  | int | max_ver = `INT_MAX`
| ) |  |

Load TBB.

The method searches the directories specified in `path`[] array for the TBB library. When the library is found, it is loaded and its version is checked. If the version is not suitable, the library is unloaded, and the search continues.

Note:

For security reasons, avoid using relative directory names. For example, never load TBB from current (`"."`), parent (`".."`) or any other relative directory (like `"lib"` ). Use only absolute directory names (e. g. "/usr/local/lib").

For the same security reasons, avoid using system default directories (`""`) on Windows. (See http://www.microsoft.com/technet/security/advisory/2269637.mspx for details.)

Neglecting these rules may cause your program to execute 3-rd party malicious code.

Errors:

- `ec_bad_call` - TBB already loaded by this object.
- `ec_bad_arg` - `min_ver` and/or `max_ver` negative or zero, or `min_ver` > `max_ver`.
- `ec_bad_ver` - TBB of unsuitable version already loaded by another object.
- `ec_no_lib` - No suitable library found.

Parameters

  path | List of directories to search TBB in.
  min_ver | Minimal suitable version of TBB.
  max_ver | Maximal suitable version of TBB.

## status()

error_code tbb::interface6::runtime_loader::status | ( |  | ) |

Report status.

If error mode is `em_status`, the function returns status of the last operation.

## Member Data Documentation

## my_loaded

bool tbb::interface6::runtime_loader::my_loaded

private

Definition at line 179 of file runtime_loader.h.

## my_mode

const error_mode tbb::interface6::runtime_loader::my_mode

private

Definition at line 177 of file runtime_loader.h.

## my_status

error_code tbb::interface6::runtime_loader::my_status

private

Definition at line 178 of file runtime_loader.h.

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

- runtime_loader.h

tbb::interface6::runtime_loader::ec_bad_ver
TBB found but version is not suitable.
Definition: runtime_loader.h:112
tbb::interface6::runtime_loader::ec_ok
No errors.
Definition: runtime_loader.h:108
tbb::interface6::runtime_loader::ec_bad_arg
Invalid argument passed.
Definition: runtime_loader.h:110
tbb::interface6::runtime_loader::ec_bad_call
Invalid function call (e. g. load() called when TBB is already loaded).
Definition: runtime_loader.h:109
tbb::interface6::runtime_loader::em_throw
Throw an exception of tbb::runtime_loader::error_code type.
Definition: runtime_loader.h:102
tbb::interface6::runtime_loader
Load TBB at runtime.
Definition: runtime_loader.h:95
tbb::interface6::runtime_loader::em_status
Save status of operation and continue.
Definition: runtime_loader.h:101
tbb::interface6::runtime_loader::ec_bad_lib
Invalid library found (e. g. TBB_runtime_version symbol not found).
Definition: runtime_loader.h:111
runtime_loader.h
path
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type size_t void ITT_FORMAT p const __itt_domain __itt_id __itt_string_handle const wchar_t size_t ITT_FORMAT lu const __itt_domain __itt_id __itt_relation __itt_id ITT_FORMAT p const wchar_t int ITT_FORMAT __itt_group_mark d __itt_event ITT_FORMAT __itt_group_mark d void const wchar_t const wchar_t int ITT_FORMAT __itt_group_sync __itt_group_fsync x void const wchar_t int const wchar_t int int ITT_FORMAT __itt_group_sync __itt_group_fsync x void ITT_FORMAT __itt_group_sync __itt_group_fsync p void ITT_FORMAT __itt_group_sync __itt_group_fsync p void size_t ITT_FORMAT lu no args __itt_obj_prop_t __itt_obj_state_t ITT_FORMAT d const char ITT_FORMAT s const char ITT_FORMAT s __itt_frame ITT_FORMAT p __itt_counter ITT_FORMAT p __itt_counter unsigned long long ITT_FORMAT lu __itt_counter unsigned long long ITT_FORMAT lu __itt_counter __itt_clock_domain unsigned long long void ITT_FORMAT p const wchar_t ITT_FORMAT S __itt_mark_type const wchar_t ITT_FORMAT S __itt_mark_type const char ITT_FORMAT s __itt_mark_type ITT_FORMAT d __itt_caller ITT_FORMAT p __itt_caller ITT_FORMAT p no args const __itt_domain __itt_clock_domain unsigned long long __itt_id ITT_FORMAT lu const __itt_domain __itt_clock_domain unsigned long long __itt_id __itt_id void ITT_FORMAT p const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_clock_domain unsigned long long __itt_id __itt_string_handle __itt_scope ITT_FORMAT d const __itt_domain __itt_scope __itt_string_handle const char size_t ITT_FORMAT lu const __itt_domain __itt_clock_domain unsigned long long __itt_relation __itt_id ITT_FORMAT lu __itt_track_group __itt_string_handle __itt_track_group_type ITT_FORMAT d __itt_track ITT_FORMAT p void int const int int const char int ITT_FORMAT d void void const char * path
Definition: ittnotify_static.h:346
tbb::interface6::runtime_loader::ec_no_lib
No suitable TBB library found.
Definition: runtime_loader.h:113
tbb::interface6::runtime_loader::em_abort
Print message to stderr and call abort().
Definition: runtime_loader.h:103

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.