Sha256: 912162c5ed2dd1a98a54a2411ab162ed19b539b44e32606d5baef537a8a3ff05

Contents?: true

Size: 589 Bytes

Versions: 9

Compression:

Stored size: 589 Bytes

Contents

require 'fiber'

module LightIO::Core
  # LightFiber is internal represent, we make slight extend on ruby Fiber to bind fibers to IOLoop
  #
  # SHOULD NOT BE USED DIRECTLY
  class LightFiber < Fiber
    attr_reader :ioloop
    attr_accessor :on_transfer

    ROOT_FIBER = Fiber.current

    def initialize(ioloop: IOloop.current, &blk)
      @ioloop = ioloop
      super(&blk)
    end

    def transfer
      on_transfer.call(LightFiber.current, self) if on_transfer
      super
    end

    class << self
      def is_root?(fiber)
        ROOT_FIBER == fiber
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
lightio-0.4.4 lib/lightio/core/light_fiber.rb
lightio-0.4.3 lib/lightio/core/light_fiber.rb
lightio-0.4.2 lib/lightio/core/light_fiber.rb
lightio-0.4.1 lib/lightio/core/light_fiber.rb
lightio-0.4.0 lib/lightio/core/light_fiber.rb
lightio-0.4.0.pre lib/lightio/core/light_fiber.rb
lightio-0.3.2 lib/lightio/core/light_fiber.rb
lightio-0.3.1 lib/lightio/core/light_fiber.rb
lightio-0.3.0 lib/lightio/core/light_fiber.rb