Skip to content
Daniel Pepper edited this page Mar 13, 2022 · 3 revisions

Berater::Lock

Each call to .limit yields a lock when successful, or an exception when the limiter is out of capacity.

  • .capacity - capacity limitation
  • .contention - capacity being utilized
  • .locked? - whether the lock is currently being held
  • .release - release capacity being held

eg.

Berater(*) do |lock|
  lock.contention
end

# or inline
lock = Berater(*).limit
...
lock.release

When limiters are used in block mode, locks can largely be ignored since .release is automatically called after the block executes.

Clone this wiki locally