Skip to content

Commit

Permalink
Merge pull request #77 from kaspth/litescheduler-typo-and-explaining-…
Browse files Browse the repository at this point in the history
…method

Litescheduler: fix typo and add explaining method
  • Loading branch information
oldmoe authored Jan 27, 2024
2 parents 2347598 + 400bbb5 commit ec19892
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/litestack/litescheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ def self.spawn(&block)
end

def self.storage
if backend == :fiber || backend == :poylphony
if fiber_backed?
Fiber.current.storage
else
Thread.current
end
end

def self.current
if backend == :fiber || backend == :poylphony
if fiber_backed?
Fiber.current
else
Thread.current
Expand All @@ -64,15 +64,15 @@ def self.switch
# they must send (true) as a parameter to this method
# else it is a no-op for fibers
def self.synchronize(fiber_sync = false, &block)
if (backend == :fiber) || (backend == :polyphony)
if fiber_backed?
yield # do nothing, just run the block as is
else
mutex.synchronize(&block)
end
end

def self.max_contexts
return 50 if backend == :fiber || backend == :polyphony
return 50 if fiber_backed?
5
end

Expand All @@ -81,4 +81,10 @@ def self.mutex
# a single mutex per process (is that ok?)
@@mutex ||= Mutex.new
end

private

def self.fiber_backed?
backend == :fiber || backend == :polyphony
end
end

0 comments on commit ec19892

Please sign in to comment.