Skip to content

Add Crystal::Lock#16768

Merged
straight-shoota merged 1 commit intocrystal-lang:masterfrom
ysbaddaden:feature/add-crystal-lock
Mar 24, 2026
Merged

Add Crystal::Lock#16768
straight-shoota merged 1 commit intocrystal-lang:masterfrom
ysbaddaden:feature/add-crystal-lock

Conversation

@ysbaddaden
Copy link
Copy Markdown
Collaborator

@ysbaddaden ysbaddaden commented Mar 20, 2026

Always checked alternative to Sync::Mutex and Sync::RWLock in a single and significantly smaller type (no crystal type id, no lock type, no reentrancy counter) at 24 bytes instead of 40 bytes. The API is also limited to #lock(&) and #rlock(&) and it raises on deadlock.

Extracted from #16756.

NOTE: this is for specific internal usages where we want simple safety; we won't need an unchecked lock (use Sync::MU directly) or a reentrant lock (use Sync::Mutex or Sync::RWLock) types.

Always checked alternative to Sync::Mutex and Sync::RWLock in a single
and significantly smaller type (no crystal type id, no lock type, no
reentrancy counter) at 24 bytes instead of 40 bytes.
@straight-shoota straight-shoota added this to the 1.20.0 milestone Mar 23, 2026
@ysbaddaden ysbaddaden moved this from Review to Approved in Multi-threading Mar 23, 2026
@straight-shoota straight-shoota merged commit 75dcbce into crystal-lang:master Mar 24, 2026
51 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in Multi-threading Mar 24, 2026
@ysbaddaden ysbaddaden deleted the feature/add-crystal-lock branch March 24, 2026 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants