Sha256: fc14af613de6bbe5de13ff0a91ce8e0d74e36a7fc2d746ddccf7472849acc957
Contents?: true
Size: 820 Bytes
Versions: 73
Compression:
Stored size: 820 Bytes
Contents
require 'thread' describe Mutex do before do @mutex = Mutex.new end it "cannot be locked twice" do @mutex.lock lambda do @mutex.lock end.should raise_error(ThreadError) end it "reports locked? status" do @mutex.locked?.should be_false @mutex.lock @mutex.locked?.should be_true end it "reports locked? status with try_lock" do @mutex.try_lock.should be_true @mutex.locked?.should be_true @mutex.try_lock.should be_false end it "is locked and unlocked by synchronize" do @mutex.synchronize do @mutex.locked?.should be_true end @mutex.locked?.should be_false end it "will not be locked by synchronize if already locked" do @mutex.lock lambda do @mutex.synchronize {} end.should raise_error(ThreadError) end end
Version data entries
73 entries across 73 versions & 3 rubygems