Skip to content

Commit 60d7778

Browse files
committed
WIP: add MT support to Crystal::EventLoop::IoUring ... [skip ci]
1 parent a3a3019 commit 60d7778

File tree

12 files changed

+427
-178
lines changed

12 files changed

+427
-178
lines changed

src/crystal/event_loop.cr

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ abstract class Crystal::EventLoop
2828
end
2929

3030
# Creates an event loop instance
31-
def self.create : self
32-
backend_class.new
31+
def self.create(parallelism : Int32 = 1) : self
32+
backend_class.new(parallelism)
3333
end
3434

3535
def self.default_file_blocking? : Bool
@@ -58,6 +58,21 @@ abstract class Crystal::EventLoop
5858
{% end %}
5959
end
6060

61+
{% if flag?(:execution_context) %}
62+
# Called whenever the parallelism of the `Fiber::ExecutionContext` is
63+
# changed (i.e. when a parallel context is resized).
64+
def on_parallelism_change(parallelism : Int32)
65+
end
66+
67+
# Called once before *scheduler* is started. Optional hook.
68+
def register(scheduler : Fiber::ExecutionContext::Scheduler, index : Int32) : Nil
69+
end
70+
71+
# Called once before *scheduler* shutdown. Optional hook.
72+
def unregister(scheduler : Fiber::ExecutionContext::Scheduler) : Nil
73+
end
74+
{% end %}
75+
6176
# Runs the loop.
6277
#
6378
# Returns immediately if events are activable. Set `blocking` to false to

src/crystal/event_loop/epoll.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ require "../system/unix/eventfd"
44
require "../system/unix/timerfd"
55

66
class Crystal::EventLoop::Epoll < Crystal::EventLoop::Polling
7-
def initialize
7+
def initialize(parallelism : Int32)
88
# the epoll instance
99
@epoll = System::Epoll.new
1010

0 commit comments

Comments
 (0)