class Innertube::Pool::Element
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.
Attributes
object[R]
owner[R]
Public Class Methods
new(object)
click to toggle source
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
Public Instance Methods
lock()
click to toggle source
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
locked?()
click to toggle source
@return [true,false] Is this element locked/claimed?
# File lib/innertube.rb, line 36 def locked? !unlocked? end
unlock()
click to toggle source
Releases this element of the pool from the current Thread.
# File lib/innertube.rb, line 41 def unlock @owner = nil end
unlocked?()
click to toggle source
@return [true,false] Is this element available for use?
# File lib/innertube.rb, line 46 def unlocked? owner.nil? end