Class: PhusionPassenger::AnalyticsLogger::Connection
- Defined in:
- lib/phusion_passenger/analytics_logger.rb
Instance Attribute Summary collapse
-
#channel ⇒ Object
Returns the value of attribute channel.
-
#mutex ⇒ Object
readonly
Returns the value of attribute mutex.
Instance Method Summary collapse
- #connected? ⇒ Boolean
- #disconnect ⇒ Object
-
#initialize(io) ⇒ Connection
constructor
A new instance of Connection.
- #ref ⇒ Object
- #synchronize ⇒ Object
- #unref ⇒ Object
Constructor Details
#initialize(io) ⇒ Connection
Returns a new instance of Connection.
386 387 388 389 390 |
# File 'lib/phusion_passenger/analytics_logger.rb', line 386 def initialize(io) @mutex = Mutex.new @refcount = 1 @channel = MessageChannel.new(io) if io end |
Instance Attribute Details
#channel ⇒ Object
Returns the value of attribute channel.
384 385 386 |
# File 'lib/phusion_passenger/analytics_logger.rb', line 384 def channel @channel end |
#mutex ⇒ Object (readonly)
Returns the value of attribute mutex.
383 384 385 |
# File 'lib/phusion_passenger/analytics_logger.rb', line 383 def mutex @mutex end |
Instance Method Details
#connected? ⇒ Boolean
392 393 394 |
# File 'lib/phusion_passenger/analytics_logger.rb', line 392 def connected? return !!@channel end |
#disconnect ⇒ Object
396 397 398 399 |
# File 'lib/phusion_passenger/analytics_logger.rb', line 396 def disconnect @channel.close if @channel @channel = nil end |
#ref ⇒ Object
401 402 403 |
# File 'lib/phusion_passenger/analytics_logger.rb', line 401 def ref @refcount += 1 end |
#synchronize ⇒ Object
412 413 414 415 416 |
# File 'lib/phusion_passenger/analytics_logger.rb', line 412 def synchronize @mutex.synchronize do yield end end |
#unref ⇒ Object
405 406 407 408 409 410 |
# File 'lib/phusion_passenger/analytics_logger.rb', line 405 def unref @refcount -= 1 if @refcount == 0 disconnect end end |