GenerationManager — Documentation by YARD 0.9.37 (original) (raw)

Class: Mongo::Server::ConnectionPool::GenerationManagerPrivate

Inherits:

Object

Defined in:

lib/mongo/server/connection_pool/generation_manager.rb

Overview

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 Attribute Summary collapse

Instance Method Summarycollapse

Constructor Details

#initialize(server:) ⇒ GenerationManager

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

| 25 26 27 28 29 30 31 | # File 'lib/mongo/server/connection_pool/generation_manager.rb', line 25 def initialize(server:) @map = Hash.new { |hash, key| hash[key] = 1 } @pipe_fds = Hash.new { | hash, key| hash[key] = { 1 => IO.pipe } } @server = server @lock = Mutex.new @scheduled_for_close = [] end | | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |

Instance Attribute Details

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

33 34 35 # File 'lib/mongo/server/connection_pool/generation_manager.rb', line 33 def server @server end

Instance Method Details

#bump(service_id: nil) ⇒ 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.

| 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | # File 'lib/mongo/server/connection_pool/generation_manager.rb', line 66 def bump(service_id: nil) @lock.synchronize do close_all_scheduled if service_id gen = @map[service_id] += 1 @pipe_fds[service_id] ||= {} @pipe_fds[service_id][gen] = IO.pipe else @map.each do | k, v| gen = @map[k] += 1 @pipe_fds[service_id] | |= {} @pipe_fds[service_id][gen] = IO.pipe end end end end | | -------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |

#generation(service_id: nil) ⇒ 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.

35 36 37 38 39 40 41 # File 'lib/mongo/server/connection_pool/generation_manager.rb', line 35 def generation(service_id: nil) validate_service_id!(service_id) @lock.synchronize do @map[service_id] end end

#generation_unlocked(service_id: nil) ⇒ 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.

43 44 45 46 47 # File 'lib/mongo/server/connection_pool/generation_manager.rb', line 43 def generation_unlocked(service_id: nil) validate_service_id!(service_id) @map[service_id] end

#pipe_fds(service_id: nil) ⇒ 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.

49 50 51 # File 'lib/mongo/server/connection_pool/generation_manager.rb', line 49 def pipe_fds(service_id: nil) @pipe_fds[service_id][@map[service_id]] end

#remove_pipe_fds(generation, service_id: nil) ⇒ 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.

53 54 55 56 57 58 59 60 61 62 63 64 # File 'lib/mongo/server/connection_pool/generation_manager.rb', line 53 def remove_pipe_fds(generation, service_id: nil) validate_service_id!(service_id) r, w = @pipe_fds[service_id].delete(generation) w.close @scheduled_for_close << r end