Sha256: 6ece386ce0bd3ee14326e4c5cbe30622c5b7e406a82ae43c549bd2d0e3dedfb7

Contents?: true

Size: 411 Bytes

Versions: 4

Compression:

Stored size: 411 Bytes

Contents

# frozen_string_literal: true

require 'bundler/setup'
require 'polyphony'

@op_count = 0

def lengthy_op
  100.times do
    orig_sleep 0.01
    @op_count += 1
  end
  @op_count
end

spin do
  cancel_after(0.1) do
    data = Polyphony::Thread.process { lengthy_op }
    puts "slept #{data} times"
  end
rescue Exception => e
  puts "error: #{e}"
ensure
  sleep 0.1
  puts "slept #{@op_count} times"
end

suspend

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
polyphony-0.26 examples/core/xx-thread_cancel.rb
polyphony-0.25 examples/core/xx-thread_cancel.rb
polyphony-0.24 examples/core/xx-thread_cancel.rb
polyphony-0.23 examples/core/thread_cancel.rb