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
94
# 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
  @idle_time = nil

  # 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.



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

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.



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

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.



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

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.



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

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.



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

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