123456789_123456789_123456789_123456789_123456789_

Class: ActiveSupport::Testing::Parallelization::SharedQueueDistributor

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: ActiveSupport::Testing::Parallelization::TestDistributor
Defined in: activesupport/lib/active_support/testing/parallelization/test_distributor.rb

Overview

Shared queue distributor - workers compete for tests (work stealing). Internal/testing helper; not exposed as a public distribution mode.

Class Method Summary

Instance Attribute Summary

TestDistributor - Inherited

#pending?

Check if there is pending work.

Instance Method Summary

TestDistributor - Inherited

#add_test

Add a test to be distributed to workers.

#close

Close the distributor.

#interrupt

Clear all pending work (called on interrupt).

#take

Retrieve the next test for a specific worker.

Constructor Details

.newSharedQueueDistributor

[ GitHub ]

  
# File 'activesupport/lib/active_support/testing/parallelization/test_distributor.rb', line 42

def initialize
  @queue = Queue.new
end

Instance Attribute Details

#pending?Boolean (readonly)

[ GitHub ]

  
# File 'activesupport/lib/active_support/testing/parallelization/test_distributor.rb', line 58

def pending?
  !@queue.empty?
end

Instance Method Details

#add_test(test)

[ GitHub ]

  
# File 'activesupport/lib/active_support/testing/parallelization/test_distributor.rb', line 46

def add_test(test)
  @queue << test
end

#close

[ GitHub ]

  
# File 'activesupport/lib/active_support/testing/parallelization/test_distributor.rb', line 62

def close
  @queue.close
end

#interrupt

[ GitHub ]

  
# File 'activesupport/lib/active_support/testing/parallelization/test_distributor.rb', line 54

def interrupt
  @queue.clear
end

#take

[ GitHub ]

  
# File 'activesupport/lib/active_support/testing/parallelization/test_distributor.rb', line 50

def take(...)
  @queue.pop
end