Skip to content

Commit 5860b0d

Browse files
committed
Renamed internal executor methods with 'ns_' convention.
1 parent f382c81 commit 5860b0d

11 files changed

+26
-34
lines changed

lib/concurrent/executor/abstract_executor_service.rb

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def auto_terminate=(value)
6262
synchronize { self.ns_auto_terminate = value }
6363
end
6464

65-
protected
65+
private
6666

6767
# Handler which executes the `fallback_policy` once the queue size
6868
# reaches `max_queue`.
@@ -89,28 +89,26 @@ def handle_fallback(*args)
8989
end
9090
end
9191

92-
def execute(*args, &task)
92+
def ns_execute(*args, &task)
9393
raise NotImplementedError
9494
end
9595

96-
# @!macro [attach] executor_service_method_shutdown_execution
96+
# @!macro [attach] executor_service_method_ns_shutdown_execution
9797
#
9898
# Callback method called when an orderly shutdown has completed.
9999
# The default behavior is to signal all waiting threads.
100-
def shutdown_execution
100+
def ns_shutdown_execution
101101
# do nothing
102102
end
103103

104-
# @!macro [attach] executor_service_method_kill_execution
104+
# @!macro [attach] executor_service_method_ns_kill_execution
105105
#
106106
# Callback method called when the executor has been killed.
107107
# The default behavior is to do nothing.
108-
def kill_execution
108+
def ns_kill_execution
109109
# do nothing
110110
end
111111

112-
protected
113-
114112
def ns_auto_terminate?
115113
!!@auto_terminate
116114
end

lib/concurrent/executor/java_executor_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def kill
5757
end
5858
end
5959

60-
protected
60+
private
6161

6262
def ns_running?
6363
!(ns_shuttingdown? || ns_shutdown?)

lib/concurrent/executor/java_single_thread_executor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def initialize(opts = {})
1717
super(opts)
1818
end
1919

20-
protected
20+
private
2121

2222
def ns_initialize(opts)
2323
@executor = java.util.concurrent.Executors.newSingleThreadExecutor

lib/concurrent/executor/java_thread_pool_executor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def running?
8787
super && !@executor.isTerminating
8888
end
8989

90-
protected
90+
private
9191

9292
def ns_initialize(opts)
9393
min_length = opts.fetch(:min_threads, DEFAULT_MIN_POOL_SIZE).to_i

lib/concurrent/executor/ruby_executor_service.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def post(*args, &task)
1919
synchronize do
2020
# If the executor is shut down, reject this task
2121
return handle_fallback(*args, &task) unless running?
22-
execute(*args, &task)
22+
ns_execute(*args, &task)
2323
true
2424
end
2525
end
@@ -29,7 +29,7 @@ def shutdown
2929
break unless running?
3030
self.ns_auto_terminate = false
3131
stop_event.set
32-
shutdown_execution
32+
ns_shutdown_execution
3333
end
3434
true
3535
end
@@ -39,7 +39,7 @@ def kill
3939
break if shutdown?
4040
self.ns_auto_terminate = false
4141
stop_event.set
42-
kill_execution
42+
ns_kill_execution
4343
stopped_event.set
4444
end
4545
true
@@ -49,11 +49,11 @@ def wait_for_termination(timeout = nil)
4949
stopped_event.wait(timeout)
5050
end
5151

52-
protected
52+
private
5353

5454
attr_reader :stop_event, :stopped_event
5555

56-
def shutdown_execution
56+
def ns_shutdown_execution
5757
stopped_event.set
5858
end
5959

lib/concurrent/executor/ruby_single_thread_executor.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def initialize(opts = {})
1616
super
1717
end
1818

19-
protected
19+
private
2020

2121
def ns_initialize(opts)
2222
@queue = Queue.new
@@ -27,19 +27,19 @@ def ns_initialize(opts)
2727
end
2828

2929
# @!visibility private
30-
def execute(*args, &task)
30+
def ns_execute(*args, &task)
3131
supervise
3232
@queue << [args, task]
3333
end
3434

3535
# @!visibility private
36-
def shutdown_execution
36+
def ns_shutdown_execution
3737
@queue << :stop
3838
stopped_event.set unless alive?
3939
end
4040

4141
# @!visibility private
42-
def kill_execution
42+
def ns_kill_execution
4343
@queue.clear
4444
@thread.kill if alive?
4545
end

lib/concurrent/executor/ruby_thread_pool_executor.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def worker_died(worker)
9595
synchronize { ns_worker_died worker }
9696
end
9797

98-
protected
98+
private
9999

100100
# @!visibility private
101101
def ns_initialize(opts)
@@ -142,8 +142,6 @@ def ns_execute(*args, &task)
142142
# raise unless @ready.empty? || @queue.empty? # assert
143143
end
144144

145-
alias_method :execute, :ns_execute
146-
147145
# @!visibility private
148146
def ns_shutdown_execution
149147
if @pool.empty?
@@ -158,8 +156,6 @@ def ns_shutdown_execution
158156
# raise unless @ready.empty? || @queue.empty? # assert
159157
end
160158

161-
alias_method :shutdown_execution, :ns_shutdown_execution
162-
163159
# @!visibility private
164160
def ns_kill_execution
165161
# TODO log out unprocessed tasks in queue
@@ -169,8 +165,6 @@ def ns_kill_execution
169165
@ready.clear
170166
end
171167

172-
alias_method :kill_execution, :ns_kill_execution
173-
174168
# tries to assign task to a worker, tries to get one from @ready or to create new one
175169
# @return [true, false] if task is assigned to a worker
176170
#

lib/concurrent/executor/serialized_execution.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def posts(posts)
6565
true
6666
end
6767

68-
protected
68+
private
6969

7070
def ns_initialize
7171
@being_executed = false

lib/concurrent/executor/simple_executor_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def wait_for_termination(timeout = nil)
8989
@stopped.wait(timeout)
9090
end
9191

92-
protected
92+
private
9393

9494
def ns_initialize
9595
@running = Concurrent::AtomicBoolean.new(true)

lib/concurrent/executor/timer_set.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def kill
6565

6666
private :<<
6767

68-
protected
68+
private
6969

7070
# Initialize the object.
7171
#
@@ -118,7 +118,7 @@ def remove_task(task)
118118
# `ExecutorServic` callback called during shutdown.
119119
#
120120
# @!visibility private
121-
def shutdown_execution
121+
def ns_shutdown_execution
122122
@queue.clear
123123
@timer_executor.kill
124124
stopped_event.set

0 commit comments

Comments
 (0)