Copyright | (c) CNRS 2024-Present |
---|---|
License | AGPL + CECILL v3 |
Maintainer | team@gargantext.org |
Stability | experimental |
Portability | POSIX |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Control.Concurrent.Throttle
Description
Documentation
throttle :: (Ord id, Eq id, Show id) => Int -> TChan (id, a) -> (a -> IO ()) -> IO () Source #
Throttling with given interval. Here, throttling means: perform
action only as frequently as allowed and other calls are DROPPED. This
is in contrast to things like Conduit throttling, where actions are
just SLOWED DOWN. We use this for asynchronous notifications and, if
messages are the same, we can just drop them safely. Our input is the
provided TChan
.
This function should be spawned as a thread.
We provide separate id
and a
. id
is used for uniquely
identifying groups of throttled messages, while a
are actual
messages that are sent to action
callback.