Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Fiber#enqueue #14561

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions spec/std/channel_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 2,8 @@ require "spec"
require "./spec_helper"

private def yield_to(fiber)
Crystal::Scheduler.enqueue(Fiber.current)
Crystal::Scheduler.resume(fiber)
Fiber.current.enqueue
fiber.resume
end

private macro parallel(*jobs)
Expand Down
2 changes: 1 addition & 1 deletion spec/std/concurrent/select_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 99,7 @@ describe "select" do
x = b
end
ensure
Crystal::Scheduler.enqueue(main)
main.enqueue
end

sleep
Expand Down
2 changes: 1 addition & 1 deletion src/channel.cr
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 744,7 @@ class Channel(T)

def time_expired(fiber : Fiber) : Nil
if @select_context.try &.try_trigger
Crystal::Scheduler.enqueue fiber
fiber.enqueue
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions src/crystal/system/unix/event_loop_libevent.cr
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 26,7 @@ class Crystal::LibEvent::EventLoop < Crystal::EventLoop
# Create a new resume event for a fiber.
def create_resume_event(fiber : Fiber) : Crystal::EventLoop::Event
event_base.new_event(-1, LibEvent2::EventFlags::None, fiber) do |s, flags, data|
Crystal::Scheduler.enqueue data.as(Fiber)
data.as(Fiber).enqueue
end
end

Expand All @@ -38,7 38,7 @@ class Crystal::LibEvent::EventLoop < Crystal::EventLoop
f.timeout_select_action = nil
select_action.time_expired(f)
else
Crystal::Scheduler.enqueue f
f.enqueue
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions src/crystal/system/win32/event_loop_iocp.cr
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 58,7 @@ class Crystal::Iocp::EventLoop < Crystal::EventLoop

timed_out = IO::Overlapped.wait_queued_completions(wait_time.total_milliseconds) do |fiber|
# This block may run multiple times. Every single fiber gets enqueued.
Crystal::Scheduler.enqueue fiber
fiber.enqueue
end

# If the wait for completion timed out we've reached the wake time and
Expand Down Expand Up @@ -90,7 90,7 @@ class Crystal::Iocp::EventLoop < Crystal::EventLoop
fiber.timeout_select_action = nil
select_action.time_expired(fiber)
else
Crystal::Scheduler.enqueue fiber
fiber.enqueue
end
end

Expand Down
4 changes: 2 additions & 2 deletions src/io/evented.cr
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 67,7 @@ module IO::Evented
@read_timed_out = timed_out

if reader = @readers.get?.try &.shift?
Crystal::Scheduler.enqueue reader
reader.enqueue
end
end

Expand All @@ -76,7 76,7 @@ module IO::Evented
@write_timed_out = timed_out

if writer = @writers.get?.try &.shift?
Crystal::Scheduler.enqueue writer
writer.enqueue
end
end

Expand Down
Loading