Skip to content

Commit 4dc5456

Browse files
committed
Use #owns_lock? helper
1 parent 92e0053 commit 4dc5456

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/sync/mutex.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module Sync
3333
def lock : Nil
3434
unless @mu.try_lock?
3535
unless @type.unchecked?
36-
if @locked_by == Fiber.current
36+
if owns_lock?
3737
raise Error::Deadlock.new unless @type.reentrant?
3838
@counter += 1
3939
return

src/sync/rw_lock.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ module Sync
8585
def lock_write : Nil
8686
unless @mu.try_lock?
8787
unless @type.unchecked?
88-
if @locked_by == Fiber.current
88+
if owns_lock?
8989
raise Error::Deadlock.new unless @type.reentrant?
9090
@counter += 1
9191
return

0 commit comments

Comments
 (0)