Skip to content

Commit

Permalink
Fix: Crystal::SpinLock doesn't need to be allocated in the HEAP
Browse files Browse the repository at this point in the history
The abstraction is a mere abstraction over an atomic integer and the
object itself are only ever used internally of other objects, with the
exception of Channel where the code explicitely accesses the ivar
directly (thus not making copies).

We can avoid a HEAP allocation everywhere we use them (i.e. in lots of
places).
  • Loading branch information
ysbaddaden committed Sep 5, 2024
1 parent f6e2ab3 commit 18daf4b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/crystal/spin_lock.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# :nodoc:
class Crystal::SpinLock
struct Crystal::SpinLock
private UNLOCKED = 0
private LOCKED = 1

Expand Down

0 comments on commit 18daf4b

Please sign in to comment.