Skip to content

Commit

Permalink
Revert "Prefer Process.pid over $$"
Browse files Browse the repository at this point in the history
This reverts commit 993a252.
  • Loading branch information
eregon committed Feb 22, 2023
1 parent 0c6f5a8 commit 8453a46
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions lib/concurrent-ruby/concurrent/async.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def initialize(delegate)
@delegate = delegate
@queue = []
@executor = Concurrent.global_io_executor
@ruby_pid = Process.pid
@ruby_pid = $$
end

# Delegates method calls to the wrapped object.
Expand Down Expand Up @@ -346,9 +346,9 @@ def perform
end

def reset_if_forked
if Process.pid != @ruby_pid
if $$ != @ruby_pid
@queue.clear
@ruby_pid = Process.pid
@ruby_pid = $$
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def ns_initialize(opts)
@completed_task_count = 0
@largest_length = 0
@workers_counter = 0
@ruby_pid = Process.pid # detects if Ruby has forked
@ruby_pid = $$ # detects if Ruby has forked

@gc_interval = opts.fetch(:gc_interval, @idletime / 2.0).to_i # undocumented
@next_gc_time = Concurrent.monotonic_time + @gc_interval
Expand Down Expand Up @@ -287,15 +287,15 @@ def ns_prune_pool
end

def ns_reset_if_forked
if Process.pid != @ruby_pid
if $$ != @ruby_pid
@queue.clear
@ready.clear
@pool.clear
@scheduled_task_count = 0
@completed_task_count = 0
@largest_length = 0
@workers_counter = 0
@ruby_pid = Process.pid
@ruby_pid = $$
end
end

Expand Down
6 changes: 3 additions & 3 deletions lib/concurrent-ruby/concurrent/executor/timer_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def ns_initialize(opts)
@task_executor = Options.executor_from_options(opts) || Concurrent.global_io_executor
@timer_executor = SingleThreadExecutor.new
@condition = Event.new
@ruby_pid = Process.pid # detects if Ruby has forked
@ruby_pid = $$ # detects if Ruby has forked
end

# Post the task to the internal queue.
Expand Down Expand Up @@ -127,10 +127,10 @@ def ns_shutdown_execution
end

def ns_reset_if_forked
if Process.pid != @ruby_pid
if $$ != @ruby_pid
@queue.clear
@condition.reset
@ruby_pid = Process.pid
@ruby_pid = $$
end
end

Expand Down

0 comments on commit 8453a46

Please sign in to comment.