FSharpx.Async icon indicating copy to clipboard operation
FSharpx.Async copied to clipboard

BlockingQueueAgent does not block on `Add` when it's full

Open vasily-kirichenko opened this issue 10 years ago • 2 comments

See https://github.com/Hopac/Hopac/blob/68ce0eb3e549664941e2777bcffd11018c0ee3fc/Docs/BoundedMb.md#about-the-blockingqueueagent

vasily-kirichenko avatar Mar 31 '15 11:03 vasily-kirichenko

Sample code:

let blockAgent = BlockingQueueAgent<int>(3)

blockAgent.Add(1)
blockAgent.Add(2)
blockAgent.Add(3)
blockAgent.Add(4) // block expected, but agent take new item to internal inbox

Xml doc of Add:

/// Asynchronously adds item to the queue. The operation ends when /// there is a place for the item. If the queue is full, the operation /// will block until some items are removed. This overload does not /// signal the caller that the item has been added.

xkrt avatar Mar 31 '15 12:03 xkrt

The only way to have the Add method adhere to the semantics of the agent is to have it call AsyncAdd (which waits on a reply from the agent) and then block on that computation. This however can defeat the purpose of Async so I'd suggest removing the Add method entirely, or perhaps change the name to something like AddForce.

eulerfx avatar Mar 31 '15 12:03 eulerfx