Class: PhusionPassenger::AnalyticsLogger::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/phusion_passenger/analytics_logger.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#channelObject

Returns the value of attribute channel.



384
385
386
# File 'lib/phusion_passenger/analytics_logger.rb', line 384

def channel
  @channel
end

#mutexObject (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

Returns:

  • (Boolean)


392
393
394
# File 'lib/phusion_passenger/analytics_logger.rb', line 392

def connected?
	return !!@channel
end

#disconnectObject



396
397
398
399
# File 'lib/phusion_passenger/analytics_logger.rb', line 396

def disconnect
	@channel.close if @channel
	@channel = nil
end

#refObject



401
402
403
# File 'lib/phusion_passenger/analytics_logger.rb', line 401

def ref
	@refcount += 1
end

#synchronizeObject



412
413
414
415
416
# File 'lib/phusion_passenger/analytics_logger.rb', line 412

def synchronize
	@mutex.synchronize do
		yield
	end
end

#unrefObject



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