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
43 44 45 46 47 |
# File 'lib/convenient_service/rspec/primitive_helpers/classes/in_threads.rb', line 43 def initialize(n, *args, &block) @n = n @args = args @block = block end |
Instance Attribute Details
#args ⇒ Object (readonly)
25 26 27 |
# File 'lib/convenient_service/rspec/primitive_helpers/classes/in_threads.rb', line 25 def args @args end |
#block ⇒ Object (readonly)
35 36 37 |
# File 'lib/convenient_service/rspec/primitive_helpers/classes/in_threads.rb', line 35 def block @block end |
#n ⇒ Object (readonly)
Returns the value of attribute n.
15 16 17 |
# File 'lib/convenient_service/rspec/primitive_helpers/classes/in_threads.rb', line 15 def n @n end |
Instance Method Details
#call ⇒ Array<Object>
Returns Thread values. Can be any type.
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/convenient_service/rspec/primitive_helpers/classes/in_threads.rb', line 59 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 |