Skip to content

Commit 8453a46

Browse files
committed
Revert "Prefer Process.pid over $$"
This reverts commit 993a252.
1 parent 0c6f5a8 commit 8453a46

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

lib/concurrent-ruby/concurrent/async.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def initialize(delegate)
290290
@delegate = delegate
291291
@queue = []
292292
@executor = Concurrent.global_io_executor
293-
@ruby_pid = Process.pid
293+
@ruby_pid = $$
294294
end
295295

296296
# Delegates method calls to the wrapped object.
@@ -346,9 +346,9 @@ def perform
346346
end
347347

348348
def reset_if_forked
349-
if Process.pid != @ruby_pid
349+
if $$ != @ruby_pid
350350
@queue.clear
351-
@ruby_pid = Process.pid
351+
@ruby_pid = $$
352352
end
353353
end
354354
end

lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def ns_initialize(opts)
138138
@completed_task_count = 0
139139
@largest_length = 0
140140
@workers_counter = 0
141-
@ruby_pid = Process.pid # detects if Ruby has forked
141+
@ruby_pid = $$ # detects if Ruby has forked
142142

143143
@gc_interval = opts.fetch(:gc_interval, @idletime / 2.0).to_i # undocumented
144144
@next_gc_time = Concurrent.monotonic_time + @gc_interval
@@ -287,15 +287,15 @@ def ns_prune_pool
287287
end
288288

289289
def ns_reset_if_forked
290-
if Process.pid != @ruby_pid
290+
if $$ != @ruby_pid
291291
@queue.clear
292292
@ready.clear
293293
@pool.clear
294294
@scheduled_task_count = 0
295295
@completed_task_count = 0
296296
@largest_length = 0
297297
@workers_counter = 0
298-
@ruby_pid = Process.pid
298+
@ruby_pid = $$
299299
end
300300
end
301301

lib/concurrent-ruby/concurrent/executor/timer_set.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def ns_initialize(opts)
7676
@task_executor = Options.executor_from_options(opts) || Concurrent.global_io_executor
7777
@timer_executor = SingleThreadExecutor.new
7878
@condition = Event.new
79-
@ruby_pid = Process.pid # detects if Ruby has forked
79+
@ruby_pid = $$ # detects if Ruby has forked
8080
end
8181

8282
# Post the task to the internal queue.
@@ -127,10 +127,10 @@ def ns_shutdown_execution
127127
end
128128

129129
def ns_reset_if_forked
130-
if Process.pid != @ruby_pid
130+
if $$ != @ruby_pid
131131
@queue.clear
132132
@condition.reset
133-
@ruby_pid = Process.pid
133+
@ruby_pid = $$
134134
end
135135
end
136136

0 commit comments

Comments
 (0)