class Async::Limiter::Unlimited

Attributes

count[R]

Public Class Methods

new(parent: nil) click to toggle source
# File lib/async/limiter/unlimited.rb, line 8
def initialize(parent: nil)
  @count = 0
  @parent = parent
end

Public Instance Methods

acquire() { || ... } click to toggle source
# File lib/async/limiter/unlimited.rb, line 36
def acquire
  @count += 1

  return unless block_given?

  begin
    yield
  ensure
    release
  end
end
async(parent: (@parent || Task.current), **options) { |task| ... } click to toggle source
# File lib/async/limiter/unlimited.rb, line 21
def async(parent: (@parent || Task.current), **options)
  acquire
  parent.async(**options) do |task|
    yield task
  ensure
    release
  end
end
blocking?() click to toggle source
# File lib/async/limiter/unlimited.rb, line 17
def blocking?
  false
end
limit() click to toggle source
# File lib/async/limiter/unlimited.rb, line 13
def limit
  Float::INFINITY
end
release() click to toggle source
# File lib/async/limiter/unlimited.rb, line 48
def release
  @count -= 1
end
sync(*queue_args) { |parent || current| ... } click to toggle source
# File lib/async/limiter/unlimited.rb, line 30
def sync(*queue_args)
  acquire(*queue_args) do
    yield(@parent || Task.current)
  end
end