Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
F# 使用BlockingCollection<';a>;。试吃#_F# - Fatal编程技术网

F# 使用BlockingCollection<';a>;。试吃#

F# 使用BlockingCollection<';a>;。试吃#,f#,F#,这与一个老问题有关: 答案或多或少是我们不能使用的,因为byref部分应该位于参数列表的末尾,这样才有可能 从这个问题开始已经过去了8年:有没有类似的带有超时的阻塞队列,我可以在F#中使用?您可以从F#中使用TryTake,没有问题,但不能将其用作元组返回。对于exmaple,在FSI中,此代码: open System.Collections.Concurrent let bc = new BlockingCollection<int>() let mutable item =

这与一个老问题有关:

答案或多或少是我们不能使用的,因为byref部分应该位于参数列表的末尾,这样才有可能


从这个问题开始已经过去了8年:有没有类似的带有超时的阻塞队列,我可以在F#中使用?

您可以从F#中使用
TryTake
,没有问题,但不能将其用作元组返回。对于exmaple,在FSI中,此代码:

open System.Collections.Concurrent

let bc = new BlockingCollection<int>()
let mutable item = 0

bc.Add 42
let success = bc.TryTake(&item, 100)
open System.Collections.Concurrent
设bc=new BlockingCollection()
设可变项=0
公元前42年
let success=bc.TryTake(&item,100)
将正常工作,并产生以下输出:

val bc : BlockingCollection<int>
val mutable item : int = 42
val success : bool = true
val bc:BlockingCollection
val可变项:int=42
val成功:bool=true

您可以使用F#中的
TryTake
,但不能将其用作元组返回。对于exmaple,在FSI中,此代码:

open System.Collections.Concurrent

let bc = new BlockingCollection<int>()
let mutable item = 0

bc.Add 42
let success = bc.TryTake(&item, 100)
open System.Collections.Concurrent
设bc=new BlockingCollection()
设可变项=0
公元前42年
let success=bc.TryTake(&item,100)
将正常工作,并产生以下输出:

val bc : BlockingCollection<int>
val mutable item : int = 42
val success : bool = true
val bc:BlockingCollection
val可变项:int=42
val成功:bool=true

注意:你可以在F#just fine中使用BlockingCollection的方法,因为参数的顺序,它不会自动执行“转换到元组返回”。注意:你可以在F#just fine中使用BlockingCollection的方法,因为参数的顺序,它不会自动执行“转换到元组返回”。