class Resource
The basic interface required by a pool resource.
Definitions
def self.call
Constructs a resource.
Implementation
def self.call
self.new
end
def initialize(concurrency = 1)
Create a new resource.
Signature
-
parameter
concurrency
Integer
The concurrency of this resource.
Implementation
def initialize(concurrency = 1)
@concurrency = concurrency
@closed = false
@count = 0
end
attr :concurrency
attr :count
def viable?
Whether this resource can be acquired.
Implementation
def viable?
!@closed
end
def closed?
Whether the resource has been closed by the user.
Implementation
def closed?
@closed
end
def close
Close the resource explicitly, e.g. the pool is being closed.
Implementation
def close
@closed = true
end
def reusable?
Whether this resource can be reused. Used when releasing resources back into the pool.
Implementation
def reusable?
!@closed
end