Skip to content

Commit

Permalink
Remove wrapper for monotonic time (#109)
Browse files Browse the repository at this point in the history
This is included in all recent MRI and JRUBY versions so the wrapper is
not needed anymore.
  • Loading branch information
ttasanen authored and mperham committed Oct 20, 2018
1 parent 306fd1b commit 3e7513c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 69 deletions.
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

0 comments on commit 3e7513c

Please sign in to comment.