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.
379 380 381 382 383 |
# File 'lib/phusion_passenger/analytics_logger.rb', line 379 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.
377 378 379 |
# File 'lib/phusion_passenger/analytics_logger.rb', line 377 def channel @channel end |
#mutex ⇒ Object (readonly)
Returns the value of attribute mutex.
376 377 378 |
# File 'lib/phusion_passenger/analytics_logger.rb', line 376 def mutex @mutex end |
Instance Method Details
#connected? ⇒ Boolean
385 386 387 |
# File 'lib/phusion_passenger/analytics_logger.rb', line 385 def connected? return !!@channel end |
#disconnect ⇒ Object
389 390 391 392 |
# File 'lib/phusion_passenger/analytics_logger.rb', line 389 def disconnect @channel.close if @channel @channel = nil end |
#ref ⇒ Object
394 395 396 |
# File 'lib/phusion_passenger/analytics_logger.rb', line 394 def ref @refcount += 1 end |
#synchronize ⇒ Object
405 406 407 408 409 |
# File 'lib/phusion_passenger/analytics_logger.rb', line 405 def synchronize @mutex.synchronize do yield end end |
#unref ⇒ Object
398 399 400 401 402 403 |
# File 'lib/phusion_passenger/analytics_logger.rb', line 398 def unref @refcount -= 1 if @refcount == 0 disconnect end end |