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.



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

#channelObject

Returns the value of attribute channel.



377
378
379
# File 'lib/phusion_passenger/analytics_logger.rb', line 377

def channel
  @channel
end

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

Returns:

  • (Boolean)


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

def connected?
	return !!@channel
end

#disconnectObject



389
390
391
392
# File 'lib/phusion_passenger/analytics_logger.rb', line 389

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

#refObject



394
395
396
# File 'lib/phusion_passenger/analytics_logger.rb', line 394

def ref
	@refcount += 1
end

#synchronizeObject



405
406
407
408
409
# File 'lib/phusion_passenger/analytics_logger.rb', line 405

def synchronize
	@mutex.synchronize do
		yield
	end
end

#unrefObject



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