matlab::cpplib::initMATLABLibraryAsync
异步初始化 MATLAB 函数库
描述
FutureResult<std::shared_ptr<MATLABLib>> initMATLABLibraryAsync(MATLABApplication & application, const std::u16string & ctfPath)
FutureResult<std::shared_ptr<MATLABLib>> initMATLABLibraryAsync(MATLABApplication & application, const std::u16string & ctfPath, const std::u16string& session_key = std::u16string())
异步初始化 MATLAB® 函数库,以便在初始化完成后获取指向新初始化的 C++ 共享库的指针。
或者,您可以指定十六进制编码的 64 字节 AES 解密密钥的附加参量,这允许您在运行时使用 C++ API 而不是 MEX 加载程序解密库。
参数
MATLABApplication & application | 从 |
const std::u16string & ctfPath | 库的名称。如果省略路径,则假定它位于当前文件夹中。有关如何使用 |
const std::u16string& session_key = std::u16string() | AES 解密密钥,指定为具有 64 字节文件大小的十六进制编码 AES 密钥。 有关详细信息,请参阅 |
返回值
|
|
异常
| 在共享库路径上未找到具有给定名称的库。 |
matlab::cpplib::LibInitErr | 无法初始化库。 |
示例
异步初始化 MATLABLibrary,并等待其初始化
auto future = mc::initMatlabLibraryAsync(matlabApplication,
mc::convertUTF8StringToUTF16String("libdoubleasync.ctf"));
if (!future.valid()) {
throw std::future_error(std::future_errc::no_state);
}
std::future_status status;
do {
status = future.wait_for(std::chrono::milliseconds(200));
if (status == std::future_status::timeout) {
std::cout << "Library initialization is in progress.\n";
} else if (status == std::future_status::ready) {
std::cout << "Library initialization has completed.\n";
}
std::this_thread::sleep_for(std::chrono::seconds(1));
} while (status != std::future_status::ready);
auto lib = future.get();
版本历史记录
在 R2018a 中推出
另请参阅
matlab::cpplib::convertUTF8StringToUTF16String | matlab::cpplib::convertUTF16StringToUTF8String | matlab::cpplib::initMATLABApplication | matlab::cpplib::runMain | matlab::cpplib::initMATLABLibrary | matlab::cpplib::MATLABLibrary::feval | matlab::cpplib::MATLABLibrary::fevalAsync | matlab::cpplib::MATLABLibrary::waitForFiguresToClose