Module: CarbonFiber

Defined in:
lib/carbon_fiber/scheduler.rb,
lib/carbon_fiber/async.rb,
lib/carbon_fiber/version.rb,
lib/carbon_fiber/io_contract.rb,
lib/carbon_fiber/native/fallback.rb

Overview

Please note that this code is heavily AI-assisted.

Defined Under Namespace

Modules: Async, Native Classes: Scheduler

Constant Summary collapse

VERSION =

Returns the current gem version.

Returns:

  • (String)

    the current gem version

"0.2.0"

Class Method Summary collapse

Class Method Details

.io_contract_v4?Boolean

Ruby 4.1 (ruby/ruby#18483) reordered the buffered scheduler hooks to io_read(io, buffer, offset, length) and made them single-transfer: one nonblocking attempt, short results returned directly, -EAGAIN instead of waiting, and zero length returns 0 without I/O. IO::Buffer::VERSION >= 3 signals the new contract; Ruby 3.4 through 4.0 define no such constant.

Returns:

  • (Boolean)

    whether this Ruby uses the v4 scheduler I/O contract



12
13
14
# File 'lib/carbon_fiber/io_contract.rb', line 12

def self.io_contract_v4?
  defined?(IO::Buffer::VERSION) ? IO::Buffer::VERSION.to_i >= 3 : false
end