#include <runtime_loader.h>
Public Types | |
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() . | |
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. | |
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. | |
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. | |
~runtime_loader () | |
Destroy object. | |
error_code | load (char const *path[], int min_ver=TBB_INTERFACE_VERSION, int max_ver=INT_MAX) |
Load TBB. | |
error_code | status () |
Report status. |
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:
runtime_loader
objects will not work (correctly) in parallel due to absence of syncronization.
Error codes.
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. |
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.
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. |
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. path | List of directories to search TBB in. |
min_ver | Minimal suitable version of TBB. |
max_ver | Maximal suitable version of TBB. |
error_code tbb::interface6::runtime_loader::status | ( | ) |
Report status.
If error mode is em_status
, the function returns status of the last operation.