Class: GrpcKit::RpcDispatcher::AutoTrimmer
- Inherits:
-
Object
- Object
- GrpcKit::RpcDispatcher::AutoTrimmer
- Defined in:
- lib/grpc_kit/rpc_dispatcher/auto_trimmer.rb
Instance Method Summary collapse
-
#initialize(pool, interval: 30) ⇒ AutoTrimmer
constructor
A new instance of AutoTrimmer.
- #start! ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(pool, interval: 30) ⇒ AutoTrimmer
Returns a new instance of AutoTrimmer.
6 7 8 9 10 |
# File 'lib/grpc_kit/rpc_dispatcher/auto_trimmer.rb', line 6 def initialize(pool, interval: 30) @pool = pool @interval = interval @running = false end |
Instance Method Details
#start! ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/grpc_kit/rpc_dispatcher/auto_trimmer.rb', line 12 def start! @running = true @thread = Thread.new do loop do unless @running GrpcKit.logger.debug('Stop AutoTrimer') break end @pool.trim sleep @interval end end end |
#stop ⇒ Object
26 27 28 29 |
# File 'lib/grpc_kit/rpc_dispatcher/auto_trimmer.rb', line 26 def stop @running = false @thread.wakeup end |