Skip to content
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
2 changes: 2 additions & 0 deletions src/fiber/execution_context/isolated.cr
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module Fiber::ExecutionContext
protected getter thread : Thread
@main_fiber : Fiber

# :nodoc:
getter event_loop : Crystal::EventLoop = Crystal::EventLoop.create

getter? running : Bool = true
Expand Down Expand Up @@ -96,6 +97,7 @@ module Fiber::ExecutionContext
@spawn_context.spawn(name: name, &block)
end

# :nodoc:
def enqueue(fiber : Fiber) : Nil
Crystal.trace :sched, "enqueue", fiber: fiber, context: self

Expand Down
6 changes: 6 additions & 0 deletions src/fiber/execution_context/multi_threaded.cr
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ module Fiber::ExecutionContext
@condition : Thread::ConditionVariable
protected getter global_queue : GlobalQueue

# :nodoc:
getter stack_pool : Fiber::StackPool = Fiber::StackPool.new

# :nodoc:
getter event_loop : Crystal::EventLoop = Crystal::EventLoop.create
@event_loop_lock = Atomic(Bool).new(false)

Expand Down Expand Up @@ -91,6 +94,7 @@ module Fiber::ExecutionContext
@size.end
end

# :nodoc:
def stack_pool? : Fiber::StackPool?
@stack_pool
end
Expand Down Expand Up @@ -156,11 +160,13 @@ module Fiber::ExecutionContext
end
end

# :nodoc:
def spawn(*, name : String? = nil, same_thread : Bool, &block : ->) : Fiber
raise ArgumentError.new("#{self.class.name}#spawn doesn't support same_thread:true") if same_thread
self.spawn(name: name, &block)
end

# :nodoc:
def enqueue(fiber : Fiber) : Nil
if ExecutionContext.current == self
# local enqueue: push to local queue of current scheduler
Expand Down
5 changes: 5 additions & 0 deletions src/fiber/execution_context/single_threaded.cr
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ module Fiber::ExecutionContext
@global_queue : GlobalQueue
@runnables : Runnables(256)

# :nodoc:
getter stack_pool : Fiber::StackPool = Fiber::StackPool.new

# :nodoc:
getter event_loop : Crystal::EventLoop = Crystal::EventLoop.create

@waiting = Atomic(Bool).new(false)
Expand Down Expand Up @@ -56,6 +59,7 @@ module Fiber::ExecutionContext
self
end

# :nodoc:
def stack_pool? : Fiber::StackPool?
@stack_pool
end
Expand Down Expand Up @@ -89,6 +93,7 @@ module Fiber::ExecutionContext
self.spawn(name: name, &block)
end

# :nodoc:
def enqueue(fiber : Fiber) : Nil
if ExecutionContext.current == self
# local enqueue
Expand Down
Loading