Sha256: 936e610e1f31dbeae182169a93f59a5015be1e71e90c05e191b9a8bee47673bb

Contents?: true

Size: 758 Bytes

Versions: 2

Compression:

Stored size: 758 Bytes

Contents

require 'spec_helper'

describe Celluloid::Waker do
  it "blocks until awoken" do
    waker = Celluloid::Waker.new
    thread = Thread.new do 
      waker.wait
      :done
    end
    
    # Assert that the thread can't be joined at this point
    thread.join(0).should be_nil
    
    waker.signal
    thread.value.should == :done
  end
  
  it "returns an IO object that can be multiplexed with IO.select" do
    waker = Celluloid::Waker.new
    waker.io.should be_an_instance_of(IO)
    
    thread = Thread.new do
      readable, _, _ = select [waker.io]
      waker.wait
      :done
    end
    
    # Assert that the thread can't be joined at this point
    thread.join(0).should be_nil
    
    waker.signal
    thread.value.should == :done
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
celluloid-0.0.3 spec/waker_spec.rb
celluloid-0.0.1 spec/waker_spec.rb