Class: ConvenientService::RSpec::Helpers::Classes::InThreads
- Inherits:
-
Support::Command
- Object
- Support::Command
- ConvenientService::RSpec::Helpers::Classes::InThreads
- Defined in:
- lib/convenient_service/rspec/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
45 46 47 48 49 |
# File 'lib/convenient_service/rspec/helpers/classes/in_threads.rb', line 45 def initialize(n, *args, &block) @n = n @args = args @block = block end |
Instance Attribute Details
#args ⇒ Object (readonly)
27 28 29 |
# File 'lib/convenient_service/rspec/helpers/classes/in_threads.rb', line 27 def args @args end |
#block ⇒ Object (readonly)
37 38 39 |
# File 'lib/convenient_service/rspec/helpers/classes/in_threads.rb', line 37 def block @block end |
#n ⇒ Object (readonly)
Returns the value of attribute n.
17 18 19 |
# File 'lib/convenient_service/rspec/helpers/classes/in_threads.rb', line 17 def n @n end |
Instance Method Details
#call ⇒ Array<Object>
Returns Thread values. Can be any type.
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/convenient_service/rspec/helpers/classes/in_threads.rb', line 61 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 |