#waiting #request #separate #synchronization-primitive #ticketed

ticketed_lock

Ticketed lock system - allows one to separate lock request from the actual waiting

3 releases (breaking)

0.3.0 Jan 25, 2021
0.2.0 Mar 4, 2017
0.1.0 Mar 3, 2017

#1357 in Concurrency

Download history 23/week @ 2024-11-27 38/week @ 2024-12-04 116/week @ 2024-12-11 27/week @ 2024-12-18 7/week @ 2024-12-25 21/week @ 2025-01-01 25/week @ 2025-01-08 49/week @ 2025-01-15 32/week @ 2025-01-22 28/week @ 2025-01-29 110/week @ 2025-02-05 61/week @ 2025-02-12 21/week @ 2025-02-19 58/week @ 2025-02-26 12/week @ 2025-03-05 54/week @ 2025-03-12

151 downloads per month

Apache-2.0

11KB
256 lines

Ticketed lock.

Ticketed lock is similar to RwLock, except that the acquisition of the lock is split:

  1. obtaining a ticket, which has to be done on the same thread as the locked storage
  2. waiting on a ticket, which puts the current thread to sleep until the ticket is due. That moment comes when all the previous tickets are processed.
  3. working with the data behind a read/lock guard
  4. when the guard is freed, it allows the following tickets to become active

A ticket can be moved between threads or even just lost. Consecutive read-only tickets do not guarantee a particular lock order. All the ticket counting is done based on Arc primitives, and the only unsafe code that this library has is for accessing the actual data behind a guard.

Dependencies

~220KB