How can I call M fuctions in different thread in mex coding matlab and C++?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
ian gong
am 27 Jul. 2021
Beantwortet: Bruno Luong
am 27 Jul. 2021
Matlab 2019b
I tried to use mexCallMATLAB in the new thread, but failed.
is there any other way to realize that calling M functions in different thread in mex coding matlab and C++?
the following is my code,hello() is a M function:
#include "mex.h"
#include <thread>
#include <stdio.h>
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
std::thread t(mexCallMATLAB(nlhs,(mxArray**)(&plhs[0]),nrhs,(mxArray**)(&prhs[0]),"hello"));
t.join();
}
0 Kommentare
Akzeptierte Antwort
Bruno Luong
am 27 Jul. 2021
No you cannot. MATLAB will crash since many MATLAB functions are not thread safe.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Write C Functions Callable from MATLAB (MEX Files) 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!