Obviously std::this_thread::sleep_for(std::chrono::milliseconds(1000)); is just an example. replacing it by : int a=2; does ntop change anything and mex test.cpp reutnrs the same error.
mex multithreading with c++
조회 수: 8 (최근 30일)
이전 댓글 표시
Hi !
I was trying to improve the speed of part of my code with a mex function. It decreased sensibly but I wante to improve it even more by using multithreading. The pure C++ function works fine, but I keep getting an error when trying to compile the mex function. I am using Matlab2019b with visual studio 2019 compiler.
I wrote the following minimal function:
#include "mex.hpp"
#include "mexAdapter.hpp"
#include <thread>
#include <chrono>
class MexFunction : public matlab::mex::Function {
public:
void operator()(matlab::mex::ArgumentList outputs, matlab::mex::ArgumentList inputs) {
std::thread t=std::thread(sleeponesec);
t.join();
}
void sleeponesec(){
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}
};
>> mex testmex.cpp
Building with 'Microsoft Visual C++ 2019'.
Error using mex
testmex.cpp
...\Mex\testmex.cpp(11): error C3867:
'MexFunction::sleeponesec': non-standard syntax; use '&' to create a pointer to member
댓글 수: 0
답변 (2개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!