Matlab编译为. NET - 线程安全怎么样?
如果我要在多线程近实时应用程序中调用由Builder NE编译的matlab函数,应该如何。我处理线程安全问题?我应该创建 matlab 对象的单个实例并在 c# 中序列化访问,还是应该为每个线程实例化一个对象?
If I to call matlab function compiled by Builder NE in multi-threaded near real-time application, how should. I approach thread safety issue? Shall I create single instance of matlab object and serialize access in c# or shall I instantiate one object for each thread?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议使用单个实例,MCR 将为您序列化访问。每个线程一个对象可能会带来太大的开销。
http:// /www.mathworks.com/support/solutions/en/data/1-ELVN0M/index.html?product=CO&solution=1-ELVN0M
*注意 - MCR 是 MATLAB 运行时,你可以想到它作为在后台运行的缩小版 MATLAB 会话。
I would suggest using a single instance, the MCR will serialize access for you. One object per thread might be too much overhead.
http://www.mathworks.com/support/solutions/en/data/1-ELVN0M/index.html?product=CO&solution=1-ELVN0M
*Note - MCR is the MATLAB runtime, you could think of it as a scaled down MATLAB session running in the backgroun.