-
Notifications
You must be signed in to change notification settings - Fork 607
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into codedb-ffi-io
- Loading branch information
Showing
77 changed files
with
1,498 additions
and
1,856 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,63 @@ | ||
module Rubinius | ||
class Fiber | ||
attr_reader :stack_size | ||
attr_reader :thread_name | ||
attr_reader :fiber_id | ||
attr_reader :source | ||
class Fiber | ||
attr_reader :stack_size | ||
attr_reader :thread_name | ||
attr_reader :fiber_id | ||
attr_reader :source | ||
|
||
def self.new(**kw, &block) | ||
if block.nil? | ||
raise ArgumentError, "Fiber.new requires a block" | ||
end | ||
|
||
def self.new(**kw, &block) | ||
if block.nil? | ||
raise ArgumentError, "Fiber.new requires a block" | ||
end | ||
stack_size = Rubinius::Type.try_convert kw[:stack_size], Fixnum, :to_int | ||
|
||
stack_size = Rubinius::Type.try_convert kw[:stack_size], Fixnum, :to_int | ||
Rubinius.invoke_primitive :fiber_new, stack_size, block, self | ||
end | ||
|
||
Rubinius.invoke_primitive :fiber_new, stack_size, block, self | ||
end | ||
def self.current | ||
Rubinius.primitive :fiber_s_current | ||
raise PrimitiveFailure, "Fiber.current primitive failed" | ||
end | ||
|
||
def self.current | ||
Rubinius.primitive :fiber_s_current | ||
raise PrimitiveFailure, "Rubinius::Fiber.current failed" | ||
end | ||
def self.yield(*args) | ||
Rubinius.primitive :fiber_s_yield | ||
raise PrimitiveFailure, "Fiber.yield primitive failed" | ||
end | ||
|
||
def self.yield(*args) | ||
Rubinius.primitive :fiber_s_yield | ||
raise PrimitiveFailure, "Rubinius::Fiber.yield failed" | ||
end | ||
def self.list | ||
Rubinius.primitive :fiber_s_list | ||
raise PrimitiveFailure, "Fiber.list primitive failed" | ||
end | ||
|
||
def resume(*args) | ||
Rubinius.primitive :fiber_resume | ||
raise PrimitiveFailure, "Rubinius::Fiber#resume failed" | ||
end | ||
def self.main | ||
Rubinius.primitive :fiber_s_main | ||
raise PrimitiveFailure, "Fiber.main primitive failed" | ||
end | ||
|
||
def transfer(*args) | ||
Rubinius.primitive :fiber_transfer | ||
raise PrimitiveFailure, "Rubinius::Fiber#transfer failed" | ||
end | ||
def status | ||
Rubinius.primitive :fiber_status | ||
raise PrimitiveFailure, "Fiber#status primitive failed" | ||
end | ||
|
||
def alive? | ||
!@dead | ||
end | ||
def resume(*args) | ||
Rubinius.primitive :fiber_resume | ||
raise PrimitiveFailure, "Fiber#resume primitive failed" | ||
end | ||
|
||
def inspect | ||
str = "#<#{self.class}:0x#{object_id.to_s(16)} thread_name=#{@thread_name} fiber_id=#{@fiber_id} status=#{alive? ? "alive" : "dead"}" | ||
str << " source=#{@source}" if @source | ||
str << ">" | ||
end | ||
def transfer(*args) | ||
Rubinius.primitive :fiber_transfer | ||
raise PrimitiveFailure, "Fiber#transfer primitive failed" | ||
end | ||
|
||
def alive? | ||
status != "dead" | ||
end | ||
|
||
def inspect | ||
str = "#<#{self.class}:0x#{object_id.to_s(16)} thread_name=#{@thread_name} fiber_id=#{@fiber_id} status=#{status}" | ||
str << " source=#{@source}" if @source | ||
str << ">" | ||
end | ||
|
||
alias_method :to_s, :inspect | ||
end |
Oops, something went wrong.