diff --git a/.travis.yml b/.travis.yml index db7840a..e2a5e68 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,8 @@ rvm: - ruby - jruby-head - jruby + - 2.3.0 + - 2.2.4 - 2.1.0 - 2.0.0 - 1.9.3 @@ -23,4 +25,4 @@ notifications: services: - redis-server env: - - CODECLIMATE_REPO_TOKEN=04a9fef09063cdef2f62cf46531329ad01a9383e3de8270e112480052774f676 \ No newline at end of file + - CODECLIMATE_REPO_TOKEN=04a9fef09063cdef2f62cf46531329ad01a9383e3de8270e112480052774f676 diff --git a/lib/rubykiq.rb b/lib/rubykiq.rb index b6737b3..b87e3d1 100644 --- a/lib/rubykiq.rb +++ b/lib/rubykiq.rb @@ -6,6 +6,8 @@ module Rubykiq extend SingleForwardable + MUTEX_FOR_PERFORM = Mutex.new + def_delegators :client, :<<, :push, :connection_pool, :connection_pool= # delegate all VALID_OPTIONS_KEYS accessors to the client @@ -25,7 +27,7 @@ def self.client(options = {}) private def self.initialize_client(options = {}) - Thread.exclusive do + MUTEX_FOR_PERFORM.synchronize do @client = Rubykiq::Client.new(options) end end diff --git a/lib/rubykiq/client.rb b/lib/rubykiq/client.rb index 96b140f..3676ea9 100644 --- a/lib/rubykiq/client.rb +++ b/lib/rubykiq/client.rb @@ -28,6 +28,8 @@ class Client queue: 'default' } + MUTEX_FOR_PERFORM = Mutex.new + # Bang open the valid options attr_accessor(*VALID_OPTIONS_KEYS) @@ -202,7 +204,7 @@ def normalize_time(time) private def initialize_connection_pool(options = {}) - Thread.exclusive do + MUTEX_FOR_PERFORM.synchronize do @connection_pool = ::ConnectionPool.new(timeout: redis_pool_timeout, size: redis_pool_size) do Rubykiq::Connection.new(options) end