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