Class: ConvenientService::RSpec::PrimitiveHelpers::Classes::InThreads
- Inherits:
-
Support::Command
- Object
- Support::Command
- ConvenientService::RSpec::PrimitiveHelpers::Classes::InThreads
- Defined in:
- lib/convenient_service/rspec/primitive_helpers/classes/in_threads.rb
Instance Attribute Summary collapse
- #args ⇒ Object readonly
- #block ⇒ Object readonly
-
#n ⇒ Object
readonly
Returns the value of attribute n.
Instance Method Summary collapse
-
#call ⇒ Array<Object>
Thread values.
- #initialize(n, *args, &block) ⇒ void constructor
Methods inherited from Support::Command
Constructor Details
#initialize(n, *args, &block) ⇒ void
48 49 50 51 52 |
# File 'lib/convenient_service/rspec/primitive_helpers/classes/in_threads.rb', line 48 def initialize(n, *args, &block) @n = n @args = args @block = block end |
Instance Attribute Details
#args ⇒ Object (readonly)
30 31 32 |
# File 'lib/convenient_service/rspec/primitive_helpers/classes/in_threads.rb', line 30 def args @args end |
#block ⇒ Object (readonly)
40 41 42 |
# File 'lib/convenient_service/rspec/primitive_helpers/classes/in_threads.rb', line 40 def block @block end |
#n ⇒ Object (readonly)
Returns the value of attribute n.
20 21 22 |
# File 'lib/convenient_service/rspec/primitive_helpers/classes/in_threads.rb', line 20 def n @n end |
Instance Method Details
#call ⇒ Array<Object>
Returns Thread values. Can be any type.
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/convenient_service/rspec/primitive_helpers/classes/in_threads.rb', line 64 def call threads = [] ## # NOTE: CRuby has GIL, so the specs are almost always successful for simple cases. # NOTE: JRuby or TruffleRuby use real threads, so NOT thread-safe code starts to fail even for the simplest cases. # n.times { threads << ::Thread.new(*args, &block) } threads.map(&:value) end |