diff options
Diffstat (limited to 'spec/ruby/core/thread/exclusive_spec.rb')
-rw-r--r-- | spec/ruby/core/thread/exclusive_spec.rb | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/spec/ruby/core/thread/exclusive_spec.rb b/spec/ruby/core/thread/exclusive_spec.rb index 522a43cac5..9de427fb52 100644 --- a/spec/ruby/core/thread/exclusive_spec.rb +++ b/spec/ruby/core/thread/exclusive_spec.rb @@ -14,5 +14,29 @@ describe "Thread.exclusive" do Thread.exclusive { :result }.should == :result end - it "needs to be reviewed for spec completeness" + it "blocks the caller if another thread is also in an exclusive block" do + m = Mutex.new + q1 = Queue.new + q2 = Queue.new + + t = Thread.new { + Thread.exclusive { + q1.push :ready + q2.pop + } + } + + q1.pop.should == :ready + + lambda { Thread.exclusive { } }.should block_caller + + q2.push :done + t.join + end + + it "is not recursive" do + Thread.exclusive do + lambda { Thread.exclusive { } }.should raise_error(ThreadError) + end + end end |