@@ -55,34 +55,36 @@ module Concurrent
5555 end
5656 end
5757
58- context 'threads naming' do
59- subject do
60- opts = { min_threads : 2 }
61- opts [ :name ] = pool_name if pool_name
62- described_class . new ( opts )
63- end
58+ if Concurrent . on_cruby? && Concurrent . ruby_version ( :>= , 2 , 3 , 0 )
59+ context 'threads naming' do
60+ subject do
61+ opts = { min_threads : 2 }
62+ opts [ :name ] = pool_name if pool_name
63+ described_class . new ( opts )
64+ end
6465
65- let ( :names ) { Concurrent ::Set . new }
66+ let ( :names ) { Concurrent ::Set . new }
6667
67- before do
68- subject . post ( names ) { |names | names << Thread . current . name }
69- subject . post ( names ) { |names | names << Thread . current . name }
70- subject . shutdown
71- subject . wait_for_termination ( pool_termination_timeout )
72- expect ( names . size ) . to eq 2
73- end
68+ before do
69+ subject . post ( names ) { |names | names << Thread . current . name }
70+ subject . post ( names ) { |names | names << Thread . current . name }
71+ subject . shutdown
72+ subject . wait_for_termination ( pool_termination_timeout )
73+ expect ( names . size ) . to eq 2
74+ end
7475
75- context 'without pool name' do
76- let ( :pool_name ) { }
77- it 'sets counted name' do
78- expect ( names . all? { |name | name =~ /^worker-\d +$/ } ) . to be true
76+ context 'without pool name' do
77+ let ( :pool_name ) { }
78+ it 'sets counted name' do
79+ expect ( names . all? { |name | name =~ /^worker-\d +$/ } ) . to be true
80+ end
7981 end
80- end
8182
82- context 'with pool name' do
83- let ( :pool_name ) { 'MyExecutor' }
84- it 'sets counted name' do
85- expect ( names . all? { |name | name =~ /^MyExecutor-worker-\d +$/ } ) . to be true
83+ context 'with pool name' do
84+ let ( :pool_name ) { 'MyExecutor' }
85+ it 'sets counted name' do
86+ expect ( names . all? { |name | name =~ /^MyExecutor-worker-\d +$/ } ) . to be true
87+ end
8688 end
8789 end
8890 end
0 commit comments