| 11 | SharedLibrary::SharedLibrary() = default; |
| 12 | |
| 13 | void SharedLibrary::load(const std::string& path, int) |
| 14 | { |
| 15 | const std::unique_lock<std::mutex> lock(_mutex); |
| 16 | |
| 17 | if(_handle != nullptr) |
| 18 | { |
| 19 | throw RuntimeError("Library already loaded: " + path); |
| 20 | } |
| 21 | |
| 22 | _handle = dlopen(path.c_str(), RTLD_NOW | RTLD_GLOBAL); |
| 23 | if(_handle == nullptr) |
| 24 | { |
| 25 | const char* err = dlerror(); |
| 26 | throw RuntimeError("Could not load library: " + |
| 27 | (err != nullptr ? std::string(err) : path)); |
| 28 | } |
| 29 | _path = path; |
| 30 | } |
| 31 | |
| 32 | void SharedLibrary::unload() |
| 33 | { |
nothing calls this directly
no test coverage detected