Skip to content

Commit

Permalink
Better organisaion of methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Jun 23, 2021
1 parent ddb83d7 commit 3aaa564
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/async/scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ def initialize(parent = nil, selector: nil)
end
end

def set!
Fiber.set_scheduler(self)
@loop = Fiber.current
end

def clear!
Fiber.set_scheduler(nil)
@loop = nil
end

def interrupt
@interrupt.signal('!')
end
Expand Down Expand Up @@ -87,10 +97,6 @@ def transfer
@loop.transfer
end

def kernel_sleep(duration)
self.block(nil, duration)
end

# Invoked when a fiber tries to perform a blocking operation which cannot continue. A corresponding call {unblock} must be performed to allow this fiber to continue.
# @reentrant Not thread safe.
def block(blocker, timeout)
Expand Down Expand Up @@ -125,20 +131,14 @@ def unblock(blocker, fiber)
end
end

def set!
Fiber.set_scheduler(self)
@loop = Fiber.current
def kernel_sleep(duration)
self.block(nil, duration)
end

def address_resolve(hostname)
::Resolv.getaddresses(hostname)
end

def clear!
Fiber.set_scheduler(nil)
@loop = nil
end

def io_wait(io, events, timeout = nil)
fiber = Fiber.current

Expand Down

0 comments on commit 3aaa564

Please sign in to comment.