Module: Gravitext::Concurrent
- Defined in:
- lib/gravitext-util/concurrent.rb
Overview
Provides a concurrent testing facility
Defined Under Namespace
Classes: BasicTestFactory, BlockTestFactory, BlockTestRunnable
Class Method Summary collapse
-
.available_cores ⇒ Object
Returns the number of available processor cores on the host.
-
.execute_runnable(test_runnable_class, runs, threads = available_cores) ⇒ Object
Run test_runnable_class instances concurrently in threads.
-
.execute_test(runs, threads = available_cores, &block) ⇒ Object
Run block concurrently in the specified number of threads.
-
.execute_test_factory(test_factory, runs, threads = available_cores) ⇒ Object
Run TestRunnable instances created from (TestFactory) test_factory concurrently with threads (one TestRunnable per thread.).
Class Method Details
.available_cores ⇒ Object
Returns the number of available processor cores on the host.
29 30 31 |
# File 'lib/gravitext-util/concurrent.rb', line 29 def self.available_cores Java::java.lang.Runtime::runtime.available_processors end |
.execute_runnable(test_runnable_class, runs, threads = available_cores) ⇒ Object
Run test_runnable_class instances concurrently in threads. The test_runnable_class should take a instance of FastRandom in its initialize(). The first of any Exceptions raised in a test thread will be re-raised in the calling thread. Returns sum of runIteration return counts.
48 49 50 51 52 |
# File 'lib/gravitext-util/concurrent.rb', line 48 def self.execute_runnable( test_runnable_class, runs, threads = available_cores ) TestExecutor::run( BasicTestFactory.new( test_runnable_class ), runs, threads ) end |
.execute_test(runs, threads = available_cores, &block) ⇒ Object
Run block concurrently in the specified number of threads. The first of any Exceptions raised in block will be re-raised in the calling thread. Returns sum of runIteration return counts.
:call-seq:
execute_test(runs,threads = available_cores) { |run,random| ... } -> Integer
60 61 62 |
# File 'lib/gravitext-util/concurrent.rb', line 60 def self.execute_test( runs, threads = available_cores, &block ) TestExecutor::run( BlockTestFactory.new( &block ), runs, threads ) end |
.execute_test_factory(test_factory, runs, threads = available_cores) ⇒ Object
Run TestRunnable instances created from (TestFactory) test_factory concurrently with threads (one TestRunnable per thread.). The first of any Exceptions raised in a test thread will be re-raised in the calling thread. Returns sum of runIteration return counts.
38 39 40 41 |
# File 'lib/gravitext-util/concurrent.rb', line 38 def self.execute_test_factory( test_factory, runs, threads = available_cores ) TestExecutor::run( test_factory, runs, threads ) end |