Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
Re: Making C++ objects persistent between mex calls, and robust.
Posted:
Nov 8, 2012 5:27 AM
|
|
"Francesco Montorsi" wrote: > Just a suggestion: why don't you create a FileExchange contribution with the C++ code and the MATLAB class wrapper? I think it would be very useful to anybody tackling this same issue! :)
Good idea. I've just submitted it, so it will appear shortly. > Finally, a question about mexLock() and mexUnlock() usage suggested in the last post: it doesn't work for me: mexLock() gets called in convertPtr2Mat() in the init_mex() MEX file, so that it will lock the "init_mex resource", but then mexUnlock() gets called in destroyObject() which is located in the clear_mex() MEX file, and will try to unlock the "clear_mex resource", which is already unlocked. Most important since the mexUnlock() call is located in a different MEX file, the one which called mexLock() will remain locked forever... > did I miss something? > do you implement the clear_mex() and init_mex() functions in the same MEX file? if so, how do you do that (as far as I know, there is only one mexFunction() possible in each MEX file)...
Ah, good point. In fact I do have just one mex function, and I access the various class methods using a command string. I mention this earlier in the thread, and you will see this in the example code.
Oliver
|
|
|
|