Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed singleton dependency #129

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/webrick/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ def random_string(len)
###########

require "timeout"
require "singleton"

##
# Class used to manage timeout handlers across multiple threads.
Expand Down Expand Up @@ -116,8 +115,6 @@ def random_string(len)
# will print 'foo'
#
class TimeoutHandler
include Singleton

##
# Mutex used to synchronize access across threads
TimeoutMutex = Thread::Mutex.new # :nodoc:
Expand All @@ -142,6 +139,11 @@ def self.terminate
instance.terminate
end

def self.instance
@instance ||= new
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this thread safe? (and/or is that a problem here?)

end
private_class_method :new

##
# Creates a new TimeoutHandler. You should use ::register and ::cancel
# instead of creating the timeout handler directly.
Expand Down