File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -16,10 +16,20 @@ class AbstractExecutorService < Synchronization::LockableObject
1616 # @!macro executor_service_attr_reader_fallback_policy
1717 attr_reader :fallback_policy
1818
19+ attr_reader :name
20+
1921 # Create a new thread pool.
2022 def initialize ( *args , &block )
2123 super ( &nil )
22- synchronize { ns_initialize ( *args , &block ) }
24+ synchronize do
25+ ns_initialize ( *args , &block )
26+ opts = args . first || { }
27+ @name = opts . fetch ( :name ) if opts . key? ( :name )
28+ end
29+ end
30+
31+ def to_s
32+ name ? "#{ super [ 0 ..-2 ] } name: #{ name } >" : super
2333 end
2434
2535 # @!macro executor_service_method_shutdown
Original file line number Diff line number Diff line change 3131 it 'defaults :fallback_policy to :abort' do
3232 expect ( subject . fallback_policy ) . to eq :abort
3333 end
34+
35+ it 'defaults :name to nil' do
36+ expect ( subject . name ) . to be_nil
37+ end
3438 end
3539
3640 context "#initialize explicit values" do
100104 described_class . new ( fallback_policy : :bogus )
101105 } . to raise_error ( ArgumentError )
102106 end
107+
108+ it 'sets :name' do
109+ pool = described_class . new ( name : 'MyPool' )
110+ expect ( pool . name ) . to eq 'MyPool'
111+ pool . shutdown
112+ pool . wait_for_termination ( pool_termination_timeout )
113+ end
103114 end
104115
105116 context '#max_queue' do
You can’t perform that action at this time.
0 commit comments