F# 是否为您提供自动并行性? [英] Does F# provide you automatic parallelism?

查看:18
本文介绍了F# 是否为您提供自动并行性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的意思是:当你设计你的应用无副作用时,F# 代码会自动分布到所有内核吗?

By this I meant: when you design your app side effects free, etc, will F# code be automatically distributed across all cores?

推荐答案

不,恐怕不行.鉴于 F# 不是纯粹的函数式语言(从最严格的意义上说),我相信这样做会相当困难.在 F# 中充分利用并行性的主要方法是使用 Async Workflows(我相信主要是通过 Async 模块).随 .NET 4.0 一起引入的 TPL(任务并行库)将在 F# 中扮演类似的角色(但值得注意的是,它可以同样好地用于所有 .NET 语言),尽管我不能说我我确定它将如何与现有的异步框架集成.也许微软会简单地建议对所有事情都使用 TPL,或者他们可能会将两者都作为一种选择,最终成为事实上的标准......

No, I'm afraid not. Given that F# isn't a pure functional language (in the strictest sense), it would be rather difficult to do so I believe. The primary way to make good use of parallelism in F# is to use Async Workflows (mainly via the Async module I believe). The TPL (Task Parallel Library), which is being introduced with .NET 4.0, is going to fulfil a similar role in F# (though notably it can be used in all .NET languages equally well), though I can't say I'm sure exactly how it's going to integrate with the existing async framework. Perhaps Microsoft will simply advise the use of the TPL for everything, or maybe they will leave both as an option and one will eventually become the de facto standard...

无论如何,这里有几篇关于 F# 中异步编程/工作流的文章可以帮助您入门.

Anyway, here are a few articles on asynchronous programming/workflows in F# to get you started.

这篇关于F# 是否为您提供自动并行性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆