An element of the pool. Comprises an object with an owning thread. Not usually needed by user code, and should not be modified outside the {Pool}'s lock.
Creates a pool element @param [Object] object the resource to wrap into the pool element
# File lib/innertube.rb, line 24 def initialize(object) @object = object @owner = nil end
Claims this element of the pool for the current Thread. Do not call this manually, it is only used from inside the pool.
# File lib/innertube.rb, line 31 def lock @owner = Thread.current end
@return [true,false] Is this element locked/claimed?
# File lib/innertube.rb, line 36 def locked? !unlocked? end
Releases this element of the pool from the current Thread.
# File lib/innertube.rb, line 41 def unlock @owner = nil end
@return [true,false] Is this element available for use?
# File lib/innertube.rb, line 46 def unlocked? owner.nil? end