Commit fd6db821 authored by Davis King's avatar Davis King

Made it so the matrix only uses matlab's allocation routines for matrices that

are directly the arguments of a mex function.  This way, we avoid the problem
of dlib::matrix objects being created in other threads that internally call
into matlab and mess it up (since matlab is not thread safe in any sense).
This diff is collapsed.
...@@ -1174,8 +1174,8 @@ namespace dlib ...@@ -1174,8 +1174,8 @@ namespace dlib
{ {
#ifdef MATLAB_MEX_FILE #ifdef MATLAB_MEX_FILE
// You can't move memory around when compiled in a matlab mex file and the // You can't move memory around when compiled in a matlab mex file and the
// different locations have different persistence settings. // different locations have different ownership settings.
if (data._private_is_persistent() == item.data._private_is_persistent()) if (data._private_is_owned_by_matlab() == item.data._private_is_owned_by_matlab())
{ {
swap(item); swap(item);
} }
...@@ -1195,8 +1195,8 @@ namespace dlib ...@@ -1195,8 +1195,8 @@ namespace dlib
{ {
#ifdef MATLAB_MEX_FILE #ifdef MATLAB_MEX_FILE
// You can't move memory around when compiled in a matlab mex file and the // You can't move memory around when compiled in a matlab mex file and the
// different locations have different persistence settings. // different locations have different ownership settings.
if (data._private_is_persistent() == rhs.data._private_is_persistent()) if (data._private_is_owned_by_matlab() == rhs.data._private_is_owned_by_matlab())
{ {
swap(rhs); swap(rhs);
} }
...@@ -1343,14 +1343,14 @@ namespace dlib ...@@ -1343,14 +1343,14 @@ namespace dlib
return data._private_release_mxArray(); return data._private_release_mxArray();
} }
void _private_mark_non_persistent() void _private_mark_owned_by_matlab()
{ {
data._private_mark_non_persistent(); data._private_mark_owned_by_matlab();
} }
bool _private_is_persistent() bool _private_is_owned_by_matlab()
{ {
return data._private_is_persistent(); return data._private_is_owned_by_matlab();
} }
#endif #endif
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment