Class: MemprofilerPprof::BlockFlusher
- Inherits:
-
Object
- Object
- MemprofilerPprof::BlockFlusher
- Defined in:
- lib/ruby_memprofiler_pprof/block_flusher.rb
Instance Attribute Summary collapse
-
#collector ⇒ Object
readonly
Returns the value of attribute collector.
Instance Method Summary collapse
-
#initialize(collector, interval: 30, logger: nil, on_flush: nil) ⇒ BlockFlusher
constructor
A new instance of BlockFlusher.
- #run ⇒ Object
- #start! ⇒ Object
- #stop! ⇒ Object
Constructor Details
#initialize(collector, interval: 30, logger: nil, on_flush: nil) ⇒ BlockFlusher
Returns a new instance of BlockFlusher.
7 8 9 10 11 12 13 |
# File 'lib/ruby_memprofiler_pprof/block_flusher.rb', line 7 def initialize(collector, interval: 30, logger: nil, on_flush: nil) @collector = collector @interval = interval @logger = logger @thread = nil @on_flush = on_flush end |
Instance Attribute Details
#collector ⇒ Object (readonly)
Returns the value of attribute collector.
5 6 7 |
# File 'lib/ruby_memprofiler_pprof/block_flusher.rb', line 5 def collector @collector end |
Instance Method Details
#run ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/ruby_memprofiler_pprof/block_flusher.rb', line 29 def run start! begin yield ensure stop! end end |
#start! ⇒ Object
15 16 17 18 19 |
# File 'lib/ruby_memprofiler_pprof/block_flusher.rb', line 15 def start! stop! @thread = Thread.new { flusher_thread } @atfork_handler = MemprofilerPprof::Atfork.at_fork(:child, &method(:at_fork_in_child)) end |
#stop! ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/ruby_memprofiler_pprof/block_flusher.rb', line 21 def stop! @thread&.kill @thread&.join @thread = nil @atfork_handler&.remove! @atfork_handler = nil end |