Class: Contender::Pool::DiscardOldestPolicy

Inherits:
RejectionPolicy show all
Defined in:
lib/contender/pool/rejection_policy.rb

Overview

Rejection policy that discards the first task in the queue and then enqueues the task

Instance Method Summary collapse

Instance Method Details

#on_rejection(task, executor) ⇒ undefined

Parameters:

Returns:

  • (undefined)


53
54
55
56
57
58
# File 'lib/contender/pool/rejection_policy.rb', line 53

def on_rejection(task, executor)
  return if executor.shutdown?

  executor.queue.poll
  executor.execute task
end