I'm use Tomas' BlockingQueueAgent and created an F# console program.
https://github.com/tpetricek/FSharp.AsyncExtensions/blob/master/src/Agents/BlockingQueueAgent.fs
I have the following code. However, the program never end. How to exit the loop in the consumer?
let producer() =
let addLinks = async {
for url in links do
do! ag.AsyncAdd(Some (url))
printfn "Producing %s" url }
async { do! addLinks
do! ag.AsyncAdd(None) }
let consumer() = async {
while true do
let! item = ag.AsyncGet()
match item with
| Some (url) ->
printfn "Consuming %s" url
....
| None ->
printfn "Done" } // How to exit the loop from here?
producer() |> Async.Start
consumer() |> Async.RunSynchronously