Sha256: 97c8f3a399d624869e698970203bafbc220586056b88545127b20e34e5dbb126

Contents?: true

Size: 886 Bytes

Versions: 5

Compression:

Stored size: 886 Bytes

Contents

Feature: wake up another event loop

  UV::Loop cannot be shared by multiple threads. To wake up a control loop in a different
  thread, use UV::Loop#async, which is thread safe

  Scenario: wake up an event loop from a different thread
    Given a file named "async_example.rb" with:
      """
      require 'uvrb'

      count = 0
      loop  = UV::Loop.default

      timer = loop.timer
      timer.start(0, 100) do |e|
        count += 1
        sleep(0.2)
      end

      callback = loop.async do |e|
        stopper = loop.timer
        stopper.start(1000, 0) do |e|
          timer.close {}
          callback.close {}
          stopper.close {}
        end
      end

      loop.work do
        callback.call
      end

      loop.run

      abort "failure, count is #{count}" if count >= 11
      """
    When I run `ruby async_example.rb`
    Then the exit status should be 0

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
uvrb-0.2.0 features/async.feature
uvrb-0.1.4 features/async.feature
uvrb-0.1.3 features/async.feature
uvrb-0.1.2 features/async.feature
uvrb-0.1.1 features/async.feature