Module: RubyRunBufferMgr__
- Included in:
- RubyRunMonitor__
- Defined in:
- lib/rubyrun/rubyrun_buffer_mgr__.rb
Overview
——————————————————————–#
#
(C) Copyright Rubysophic Inc. 2007-2008 #
All rights reserved. #
#
Use, duplication or disclosure of the code is not permitted #
unless licensed. #
#
Last Updated: 7/09/08 #
——————————————————————–#
#
RubyRunBufferMgr__ module is responsible for passing the data #
from the inline execution thread to the monitor thread #
#
Two buffers (primary and secondary) are used and the buffers are #
swapped between the inline execution thread and RubyRunMonitor__ #
thread periodically as defined by REPORT_TIMER. The inline #
execution thread pushes data into the primary buffer, when the #
REPORT_TIMER expires, RubyRunMonitor__ thread then takes it over #
and gives the inline execution thread the secondary buffer via #
a quick swap. The same process keeps repeating as the monitor #
timer pops and the primary and secondary keep switched between #
the two threads. #
#
——————————————————————–#
Instance Method Summary collapse
-
#push_current_buffer(metrics) ⇒ Object
Push data into the current buffer Primary or secondary buffer may be used but it is transparent to the caller.
-
#return_and_switch_buffer ⇒ Object
Return the current buffer and swap it with the other one This method is invoked by the consumer of the data in the buffer.
Instance Method Details
#push_current_buffer(metrics) ⇒ Object
Push data into the current buffer Primary or secondary buffer may be used but it is transparent to the caller
30 31 32 33 34 |
# File 'lib/rubyrun/rubyrun_buffer_mgr__.rb', line 30 def push_current_buffer(metrics) $rubyrun_lock.synchronize { ($rubyrun_current_buffer == 1 ? $rubyrun_prime_buffer : $rubyrun_alt_buffer) << metrics } end |
#return_and_switch_buffer ⇒ Object
Return the current buffer and swap it with the other one This method is invoked by the consumer of the data in the buffer
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rubyrun/rubyrun_buffer_mgr__.rb', line 38 def return_and_switch_buffer() $rubyrun_lock.synchronize { if ($rubyrun_current_buffer == 1) $rubyrun_current_buffer == 2 $rubyrun_prime_buffer else $rubyrun_current_buffer == 1 $rubyrun_alt_buffer end } end |