Class: Hoodoo::Communicators::Pool::QueueEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/hoodoo/communicators/pool.rb

Overview

Internal implementation detail of Hoodoo::Communicators::Pool which is placed on a Ruby Queue and used as part of thread processing for slow communicators.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload: nil, dropped: nil, terminate: false, sync: false) ⇒ QueueEntry

Create a new instance, ready to be added to the Queue.

ONLY USE ONE of the named parameters:

payload

A parameter to send to #communicate in the communicator.

dropped

The integer to send to #dropped in the communicator.

terminate

Set to true to exit the processing thread when the entry is read from the Queue.

sync

Set to true to push a message onto the sync Queue.



579
580
581
582
583
584
# File 'lib/hoodoo/communicators/pool.rb', line 579

def initialize( payload: nil, dropped: nil, terminate: false, sync: false )
  @payload   = payload
  @dropped   = dropped
  @terminate = terminate
  @sync      = sync
end

Instance Attribute Details

#droppedObject

If not nil or zero, the number of dropped messages that should be send to the slow communicator subclass’s #dropped method. See also #dropped?



561
562
563
# File 'lib/hoodoo/communicators/pool.rb', line 561

def dropped
  @dropped
end

#payloadObject

If the entry represents neither a termination request nor a dropped message count (see #terminate? and #dropped?), the payload to send to the slow communicator subclass’s #communicate method.



567
568
569
# File 'lib/hoodoo/communicators/pool.rb', line 567

def payload
  @payload
end

#syncObject

If true, the processing Thread should push one item with any payload onto its sync Queue. See also #sync?



555
556
557
# File 'lib/hoodoo/communicators/pool.rb', line 555

def sync
  @sync
end

#terminateObject

If true, the processing Thread should exit. See also #terminate?.



550
551
552
# File 'lib/hoodoo/communicators/pool.rb', line 550

def terminate
  @terminate
end

Instance Method Details

#dropped?Boolean

Returns true if this queue entry represents a dropped message count (see #dropped), else +false (see #terminate? then #payload).

Returns:

  • (Boolean)


603
604
605
# File 'lib/hoodoo/communicators/pool.rb', line 603

def dropped?
  @dropped != nil && @dropped > 0
end

#sync?Boolean

Returns true if this queue entry represents a request to push a message onto the processing Thread’s sync Queue.

Returns:

  • (Boolean)


596
597
598
# File 'lib/hoodoo/communicators/pool.rb', line 596

def sync?
  @sync == true
end

#terminate?Boolean

Returns true if encountering this queue entry should terminate the processing thread, else false (see #dropped? then #payload).

Returns:

  • (Boolean)


589
590
591
# File 'lib/hoodoo/communicators/pool.rb', line 589

def terminate?
  @terminate == true
end