-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recognize lock state of other semaphores with the same key. #46
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,15 @@ | |
expect(semaphore.locked?).to eq(false) | ||
end | ||
|
||
it "recognizes the lock state of another semaphore with the same key" do | ||
semaphore.lock(1) | ||
expect(semaphore.locked?).to eq(true) | ||
expect(semaphore2.locked?).to eq(true) | ||
semaphore.unlock | ||
expect(semaphore.locked?).to eq(false) | ||
expect(semaphore2.locked?).to eq(false) | ||
end | ||
|
||
it "should not lock twice as a mutex" do | ||
expect(semaphore.lock(1)).not_to eq(false) | ||
expect(semaphore.lock(1)).to eq(false) | ||
|
@@ -147,6 +156,7 @@ | |
|
||
describe "semaphore with expiration" do | ||
let(:semaphore) { Redis::Semaphore.new(:my_semaphore, :redis => @redis, :expiration => 2) } | ||
let(:semaphore2) { Redis::Semaphore.new(:my_semaphore, :redis => @redis, :expiration => 2) } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [96/80] |
||
let(:multisem) { Redis::Semaphore.new(:my_semaphore_2, :resources => 2, :redis => @redis, :expiration => 2) } | ||
|
||
it_behaves_like "a semaphore" | ||
|
@@ -170,6 +180,7 @@ | |
|
||
describe "semaphore without staleness checking" do | ||
let(:semaphore) { Redis::Semaphore.new(:my_semaphore, :redis => @redis) } | ||
let(:semaphore2) { Redis::Semaphore.new(:my_semaphore, :redis => @redis) } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the new Ruby 1.9 hash syntax. |
||
let(:multisem) { Redis::Semaphore.new(:my_semaphore_2, :resources => 2, :redis => @redis) } | ||
|
||
it_behaves_like "a semaphore" | ||
|
@@ -208,6 +219,7 @@ | |
|
||
describe "semaphore with staleness checking" do | ||
let(:semaphore) { Redis::Semaphore.new(:my_semaphore, :redis => @redis, :stale_client_timeout => 5) } | ||
let(:semaphore2) { Redis::Semaphore.new(:my_semaphore, :redis => @redis, :stale_client_timeout => 5) } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [106/80] |
||
let(:multisem) { Redis::Semaphore.new(:my_semaphore_2, :resources => 2, :redis => @redis, :stale_client_timeout => 5) } | ||
|
||
it_behaves_like "a semaphore" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shadowing outer local variable -
token
.