Module: Sequent::Util

Defined in:
lib/sequent/util/timer.rb,
lib/sequent/util/printer.rb,
lib/sequent/util/skip_if_already_processing.rb

Defined Under Namespace

Modules: Printer, Timer

Class Method Summary collapse

Class Method Details

.skip_if_already_processing(already_processing_key, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/sequent/util/skip_if_already_processing.rb', line 3

def self.skip_if_already_processing(already_processing_key, &block)
  return if Thread.current[already_processing_key]

  begin
    Thread.current[already_processing_key] = true

    block.yield
  ensure
    Thread.current[already_processing_key] = nil
  end
end