Sha256: 73395e7e6a6a3ec374a49a3e05110841d391dd8955376858637e3bfe3e564e51

Contents?: true

Size: 568 Bytes

Versions: 21

Compression:

Stored size: 568 Bytes

Contents

# frozen_string_literal: true

require 'bundler/setup'
require 'polyphony'
require 'polyphony/core/debug'

Exception.__disable_sanitized_backtrace__ = true

puts '----- start await example ------'
sleeper = spin do
  puts 'going to sleep'
  sleep 1
  puts 'woke up'
end

# One way to synchronize fibers is by using `Fiber#await`, which blocks
# until the fiber has finished running or has been interrupted.
waiter = spin do
  puts 'waiting for fiber to terminate'
  sleeper.await
  puts 'done waiting'
end

trace :before_await

sleep 2
waiter.await
trace :after_await

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
polyphony-1.6 examples/core/await.rb
polyphony-1.5 examples/core/await.rb
polyphony-1.4 examples/core/await.rb
polyphony-1.3 examples/core/await.rb
polyphony-1.2.1 examples/core/await.rb
polyphony-1.2 examples/core/await.rb
polyphony-1.1.1 examples/core/await.rb
polyphony-1.1 examples/core/await.rb
polyphony-1.0.2 examples/core/await.rb
polyphony-1.0.1 examples/core/await.rb
polyphony-1.0 examples/core/await.rb
polyphony-0.99.6 examples/core/await.rb
polyphony-0.99.5 examples/core/await.rb
polyphony-0.99.4 examples/core/await.rb
polyphony-0.99.3 examples/core/await.rb
polyphony-0.99.2 examples/core/await.rb
polyphony-0.99.1 examples/core/await.rb
polyphony-0.99 examples/core/await.rb
polyphony-0.98 examples/core/await.rb
polyphony-0.97 examples/core/await.rb