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 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (2)
Siehe auch
Kategorien
Mehr zu Introduction to Installation and Licensing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!