Sha256: eadd364dcc0d907ffc1f9f821698ccacd3e486d5313c903525e00c8f4bc756f5

Contents?: true

Size: 1.31 KB

Versions: 52

Compression:

Stored size: 1.31 KB

Contents

describe :thread_wakeup, :shared => true do
=begin
  it "can interrupt Kernel#sleep" do
    exit_loop = false
    after_sleep1 = false
    after_sleep2 = false

    t = Thread.new do
      while true
        break if exit_loop == true
      end

      sleep
      after_sleep1 = true

      sleep
      after_sleep2 = true
    end

    10.times { t.send(@method); Thread.pass }
    t.status.should_not == "sleep"

    exit_loop = true

    Thread.pass while t.status and t.status != "sleep"
    after_sleep1.should == false # t should be blocked on the first sleep
    t.send(@method)

    Thread.pass while after_sleep1 != true
    Thread.pass while t.status and t.status != "sleep"
    after_sleep2.should == false # t should be blocked on the second sleep
    t.send(@method)

    t.join
  end

  it "does not result in a deadlock" do
    t = Thread.new do
      1000.times {Thread.stop }
    end

    while(t.status != false) do
      begin
        t.send(@method)
      rescue ThreadError
        # The thread might die right after.
        t.status.should == false
      end
      Thread.pass
    end

    1.should == 1 # test succeeds if we reach here
  end

  it "raises a ThreadError when trying to wake up a dead thread" do
    t = Thread.new { 1 }
    t.join
    lambda { t.wakeup }.should raise_error(ThreadError)
  end
=end  
end

Version data entries

52 entries across 52 versions & 2 rubygems

Version Path
rhodes-7.6.0 spec/framework_spec/app/spec/core/thread/shared/wakeup.rb
rhodes-7.5.1 spec/framework_spec/app/spec/core/thread/shared/wakeup.rb
rhodes-7.4.1 spec/framework_spec/app/spec/core/thread/shared/wakeup.rb
rhodes-7.1.17 spec/framework_spec/app/spec/core/thread/shared/wakeup.rb
rhodes-6.2.0 spec/framework_spec/app/spec/core/thread/shared/wakeup.rb
rhodes-6.0.11 spec/framework_spec/app/spec/core/thread/shared/wakeup.rb
rhodes-5.5.18 spec/framework_spec/app/spec/core/thread/shared/wakeup.rb
rhodes-5.5.17 spec/framework_spec/app/spec/core/thread/shared/wakeup.rb
rhodes-5.5.15 spec/framework_spec/app/spec/core/thread/shared/wakeup.rb
rhodes-5.5.0.22 spec/framework_spec/app/spec/core/thread/shared/wakeup.rb
rhodes-5.5.2 spec/framework_spec/app/spec/core/thread/shared/wakeup.rb
rhodes-5.5.0.7 spec/framework_spec/app/spec/core/thread/shared/wakeup.rb
rhodes-5.5.0.3 spec/framework_spec/app/spec/core/thread/shared/wakeup.rb
rhodes-5.5.0 spec/framework_spec/app/spec/core/thread/shared/wakeup.rb
tauplatform-1.0.3 spec/framework_spec/app/spec/core/thread/shared/wakeup.rb
tauplatform-1.0.2 spec/framework_spec/app/spec/core/thread/shared/wakeup.rb
tauplatform-1.0.1 spec/framework_spec/app/spec/core/thread/shared/wakeup.rb
rhodes-3.5.1.12 spec/framework_spec/app/spec/core/thread/shared/wakeup.rb
rhodes-3.3.5 spec/framework_spec/app/spec/core/thread/shared/wakeup.rb
rhodes-3.4.2 spec/framework_spec/app/spec/core/thread/shared/wakeup.rb