Skip to content

Commit

Permalink
Fix mutex specs race condition on mt (#8643)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian J. Cardiff authored Jan 3, 2020
1 parent 090e697 commit 15bfc23
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions spec/std/mutex_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@ describe Mutex do

it "can't be unlocked by another fiber" do
mutex = nil
done = false

spawn do
mutex = Mutex.new
mutex.not_nil!.lock
done = true
end

until mutex
until done
Fiber.yield
end

Expand Down Expand Up @@ -80,13 +82,15 @@ describe Mutex do

it "can't be unlocked by another fiber" do
mutex = nil
done = false

spawn do
mutex = Mutex.new(:reentrant)
mutex.not_nil!.lock
done = true
end

until mutex
until done
Fiber.yield
end

Expand Down

0 comments on commit 15bfc23

Please sign in to comment.