mathworks / libmexclass

libmexclass is a MATLAB framework which enables users to implement the functionality of MATLAB classes in terms of equivalent C++ classes using MEX.
BSD 3-Clause "New" or "Revised" License
5 stars 1 forks source link

Make the proxy manager more thread safe #15

Closed jhughes-mw closed 1 year ago

jhughes-mw commented 1 year ago

I updated ProxyManager to use a slightly different paradigm.

It uses a static property to maintain the registered Proxies instead of a per instance property. That shouldn't make any difference since ProxyManager is a singleton anyway. This also has the effect on ensuring only one construction.

Then, since there wasn't much reason to operate directly on the instance, I made the methods static, which further hides the singleton, that really didn't improve thread safety, but it's nice.

Finally, I made the ID property an atomic to avoid multiple threads trying to update it. This might have some performance impact, but I don't think registering new proxies at a high rate of speed is required.

kevingurney commented 1 year ago

Thanks for making this change! Looks good!