[Haskell-cafe] Bounded STM Queues with load shedding

Ryan Yates fryguybob at gmail.com
Sat Feb 28 19:11:48 UTC 2015


Note that this is what orElse is for, turning a blocking API unto a
choice.  You could write tryWriteTBQueue as:

    tryWriteTBQueue queue v = (writeTBQueue queue v >> return True)
`orElse` (return False)

Ryan

On Sat, Feb 28, 2015 at 11:56 AM, Alex Hammel <ahammel87 at gmail.com> wrote:

> Perfect, thanks!
> On 28 Feb 2015 08:51, "Yuras Shumovich" <shumovichy at gmail.com> wrote:
>
>> On Sat, 2015-02-28 at 08:31 -0800, Alex Hammel wrote:
>> > Forwarding from Haskell-Beginners:
>> >
>> > Hi list,
>> >
>> > It would be handy for me to have a bounded STM Queue along the lines of
>> > TBQueue with the difference that when the queue is full, a call to
>> > writeTBQueue is a non-blocking no-op.
>> >
>> > This is in the context of an asynchronous logging system. If the load
>> > (somehow) gets heavy enough that the log message queue is taking up a
>> lot
>> > of memory, It's better to lose a few log messages than to have processes
>> > block until the logger catches up.
>> >
>> > Are there any off-the-shelf solutions?
>>
>> You can try the stm-chans package:
>>
>> http://hackage.haskell.org/package/stm-chans-3.0.0.2/docs/Control-Concurrent-STM-TBMQueue.html#v:tryWriteTBMQueue
>>
>> Thanks,
>> Yuras
>>
>> >
>> > Cheers,
>> > Alex
>> > _______________________________________________
>> > Haskell-Cafe mailing list
>> > Haskell-Cafe at haskell.org
>> > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>>
>>
>>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150228/84cdc57f/attachment.html>


More information about the Haskell-Cafe mailing list