From c16853bb142edb4d3e791f5a5e9c7232e4217d31 Mon Sep 17 00:00:00 2001 From: Alexey Osipenko Date: Mon, 18 Jan 2016 16:00:27 +0200 Subject: [PATCH 1/2] Thread.exclusive is deprecated, use Mutex It looks like Thread.exclusive is being deprecated in favor of a Mutex in Ruby. --- .travis.yml | 1 + lib/rubykiq.rb | 4 +++- lib/rubykiq/client.rb | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index db7840a..1e3acc3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ rvm: - ruby - jruby-head - jruby + - 2.3.0 - 2.1.0 - 2.0.0 - 1.9.3 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 From 7652317e2c4f87509624b3c2cba0ee866720353e Mon Sep 17 00:00:00 2001 From: Alexey Osipenko Date: Mon, 18 Jan 2016 19:23:45 +0200 Subject: [PATCH 2/2] Update .travis.yml --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1e3acc3..e2a5e68 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ rvm: - jruby-head - jruby - 2.3.0 + - 2.2.4 - 2.1.0 - 2.0.0 - 1.9.3 @@ -24,4 +25,4 @@ notifications: services: - redis-server env: - - CODECLIMATE_REPO_TOKEN=04a9fef09063cdef2f62cf46531329ad01a9383e3de8270e112480052774f676 \ No newline at end of file + - CODECLIMATE_REPO_TOKEN=04a9fef09063cdef2f62cf46531329ad01a9383e3de8270e112480052774f676