mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
22 lines
428 B
Ruby
22 lines
428 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ThreadJob < ActiveJob::Base
|
|
class << self
|
|
attr_accessor :thread
|
|
|
|
def latch
|
|
@latch ||= Concurrent::CountDownLatch.new
|
|
end
|
|
|
|
def test_latch
|
|
@test_latch ||= Concurrent::CountDownLatch.new
|
|
end
|
|
end
|
|
|
|
def perform
|
|
Thread.current[:job_ran] = true
|
|
self.class.thread = Thread.current
|
|
self.class.latch.count_down
|
|
self.class.test_latch.wait
|
|
end
|
|
end
|