F# 中的进程间通信
我正在 F# 中开发外部 DSL。该语言必须允许并行循环:
start 5 times
operation
这会异步启动操作
5 次并继续执行。然而,事情有点复杂,因为 操作
使用线程不安全的库(没有办法避免这种情况),因此我认为每次迭代都必须在单独的进程中启动。
假设这是解决线程不安全问题的唯一方法,我如何启动一个进程并传递必须执行的执行子树(此时为区分联合)?
我正在考虑 WCF 命名管道,但想听听是否有替代方案(WCF 意味着启动进程,等待回调(跟踪它)并返回子树 - 不是非常功能友好的代码,但也许我错了)。
此外,在这种情况下,性能并不是很重要。
编辑: 事实证明,流程开始后我不需要任何沟通。我很想简单地将表达式字符串作为进程启动参数传递,并让他解析/执行它。我仍然对替代方案感兴趣,但我认为没有比这更简单的了。
I'm working on an external DSL in F#. The language must allow parallel loops:
start 5 times
operation
This starts operation
asynchronously 5 times and continues with the execution. However, things are a bit complicated because operation
uses a Thread-unsafe library (no way to avoid this), thus I suppose each iteration must be started in a separate process.
Assuming this is the only way around the thread-unsafety problem, How can I start a process and pass the execution subtree (a distriminated union at this point) that must be executed?
I'm thinking WCF named pipes, but would like to hear if there are alternatives (WCF means starting the process, waiting for a call-back (keeping track of it) and returning the subtree -not very functonal-friendly code but maybe I'm wrong).
Also, performance is not really important in this case.
EDIT:
Turns out I don't need any communication after the process has started. I'm tempted to simply pass the expression string as a process startup parameter and let him parse/execute it. I'm still interested in alternatives, but I suppose it doesn't get any simpler than that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果可能的话,在单独的 AppDomain 中运行每个操作将比 IPC 更简单。
Running each operation in a separate AppDomain--if possible--would be simpler than IPC.