class Async::Pool::Resource

The basic interface required by a pool resource.

Attributes

concurrency[R]

@attr [Integer] The concurrency of this resource, 1 (singleplex) or more (multiplex).

count[R]

@attr [Integer] The number of times this resource has been used.

Public Class Methods

call() click to toggle source

Constructs a resource.

# File lib/async/pool/resource.rb, line 31
def self.call
        self.new
end
new(concurrency = 1) click to toggle source
# File lib/async/pool/resource.rb, line 35
def initialize(concurrency = 1)
        @concurrency = concurrency
        @closed = false
        @count = 0
end

Public Instance Methods

close() click to toggle source

Close the resource explicitly, e.g. the pool is being closed.

# File lib/async/pool/resource.rb, line 60
def close
        @closed = true
end
closed?() click to toggle source

Whether the resource has been closed by the user. @return [Boolean] whether the resource has been closed or has failed.

# File lib/async/pool/resource.rb, line 55
def closed?
        @closed
end
reusable?() click to toggle source

Whether this resource can be reused. Used when releasing resources back into the pool.

# File lib/async/pool/resource.rb, line 65
def reusable?
        !@closed
end
viable?() click to toggle source

Whether this resource can be acquired. @return [Boolean] whether the resource can actually be used.

# File lib/async/pool/resource.rb, line 49
def viable?
        !@closed
end