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

Remove wrapper for monotonic time #109

Merged
merged 1 commit into from Oct 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
66 changes: 0 additions & 66 deletions lib/connection_pool/monotonic_time.rb

This file was deleted.

5 changes: 2 additions & 3 deletions lib/connection_pool/timed_stack.rb
@@ -1,6 +1,5 @@
require 'thread'
require 'timeout'
require_relative 'monotonic_time'

##
# Raised when you attempt to retrieve a connection from a pool that has been
Expand Down Expand Up @@ -74,7 +73,7 @@ def pop(timeout = 0.5, options = {})
options, timeout = timeout, 0.5 if Hash === timeout
timeout = options.fetch :timeout, timeout

deadline = ConnectionPool.monotonic_time + timeout
deadline = ::Process.clock_gettime(Process::CLOCK_MONOTONIC) + timeout
@mutex.synchronize do
loop do
raise ConnectionPool::PoolShuttingDownError if @shutdown_block
Expand All @@ -83,7 +82,7 @@ def pop(timeout = 0.5, options = {})
connection = try_create(options)
return connection if connection

to_wait = deadline - ConnectionPool.monotonic_time
to_wait = deadline - ::Process.clock_gettime(Process::CLOCK_MONOTONIC)
raise Timeout::Error, "Waited #{timeout} sec" if to_wait <= 0
@resource.wait(@mutex, to_wait)
end
Expand Down