Class: Moneta::Pool::PoolManager Private

Inherits:
Object
  • Object
show all
Defined in:
lib/moneta/pool.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(builder, min: 0, max: nil, ttl: nil, timeout: nil) ⇒ PoolManager

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of PoolManager.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/moneta/pool.rb', line 73

def initialize(builder, min: 0, max: nil, ttl: nil, timeout: nil)
  @builder = builder
  @min = min
  @max = max
  @ttl = ttl
  @timeout = timeout

  @inbox = []
  @mutex = ::Mutex.new
  @resource = ::ConditionVariable.new

  @stores = Set.new
  @available = []
  @waiting = []
  @waiting_since = [] if @timeout
  @last_checkout = nil
  @stopping = false

  # Launch the manager thread
  @thread = run
end

Instance Method Details

#check_in(store) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



117
118
119
# File 'lib/moneta/pool.rb', line 117

def check_in(store)
  push(:check_in, store)
end

#check_outObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



111
112
113
114
115
# File 'lib/moneta/pool.rb', line 111

def check_out
  reply = push(:check_out, reply: true)
  raise reply if Exception === reply
  reply
end

#kill!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



106
107
108
109
# File 'lib/moneta/pool.rb', line 106

def kill!
  @thread.kill
  nil
end

#statsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



95
96
97
# File 'lib/moneta/pool.rb', line 95

def stats
  push(:stats, reply: true)
end

#stopObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



99
100
101
102
103
104
# File 'lib/moneta/pool.rb', line 99

def stop
  push(:stop)
  nil
ensure
  @thread.value
end