Resource Pool in F#
Erik Schulz, who has written a bunch of articles on how to make XNA games with F# has ported the Resource Pool class I wrote about in F#. Cool!
type FPool<'a>(newRoutine, capacity : int) =
let queue = Queue<'a> capacity
member this.Count = queue.Count
member this.New() =
if queue.Count > 0 then queue.Dequeue() else newRoutine()
member this.Return(item) =
queue.Enqueue(item)
I’ve been toying around with F# recently, it’s good to see an example that you can easily compare and contrast with the C# version. Has anyone else tried out F#?