Sha256: 150b8252b6e4edd93ed8994ee1941d00fdbd649d4d2847b170f0cdd203a42860
Contents?: true
Size: 1.78 KB
Versions: 1
Compression:
Stored size: 1.78 KB
Contents
# frozen_string_literal: true require 'modulation/gem' export_default :Polyphony require 'fiber' require_relative './gyro_ext' Thread.event_selector = Gyro::Selector Thread.current.setup_fiber_scheduling import './polyphony/extensions/core' import './polyphony/extensions/thread' import './polyphony/extensions/fiber' import './polyphony/extensions/io' # Main Polyphony API module Polyphony GlobalAPI = import './polyphony/core/global_api' ::Object.include GlobalAPI exceptions = import './polyphony/core/exceptions' Cancel = exceptions::Cancel MoveOn = exceptions::MoveOn Net = import './polyphony/net' auto_import( CancelScope: './polyphony/core/cancel_scope', Channel: './polyphony/core/channel', FS: './polyphony/fs', ResourcePool: './polyphony/core/resource_pool', Supervisor: './polyphony/core/supervisor', Sync: './polyphony/core/sync', ThreadPool: './polyphony/core/thread_pool', Throttler: './polyphony/core/throttler', Trace: './polyphony/trace', Websocket: './polyphony/websocket' ) class << self # def trap(sig, ref = false, &callback) # sig = Signal.list[sig.to_s.upcase] if sig.is_a?(Symbol) # puts "sig = #{sig.inspect}" # watcher = Gyro::Signal.new(sig, &callback) # # Gyro.unref unless ref # watcher # end def wait_for_signal(sig) fiber = Fiber.current Gyro.ref trap(sig) do trap(sig, :DEFAULT) Gyro.unref fiber.transfer(sig) end suspend end def fork(&block) pid = Kernel.fork do Gyro.post_fork Fiber.current.setup_main_fiber block.() end pid end def reset! Thread.current.reset_fiber_scheduling Fiber.reset! end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
polyphony-0.29 | lib/polyphony.rb |