F# 中的进程间通信

发布于 2024-12-21 18:47:43 字数 485 浏览 3 评论 0原文

我正在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

肤浅与狂妄 2024-12-28 18:47:43

如果可能的话,在单独的 AppDomain 中运行每个操作将比 IPC 更简单。

Running each operation in a separate AppDomain--if possible--would be simpler than IPC.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文