em-synchrony 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/em-synchrony.gemspec +1 -1
- data/lib/active_record/connection_adapters/em_mysql2_adapter.rb +1 -1
- data/lib/em-synchrony/activerecord.rb +11 -3
- data/lib/em-synchrony/kernel.rb +3 -3
- data/spec/activerecord_spec.rb +1 -0
- data/spec/kernel_override_spec.rb +12 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28e9e5eb599e7f7d72c090f0626fffb94a641c67
|
4
|
+
data.tar.gz: 379c553f5e1ac9d2f0086c1e47f5cb7980c1b6e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd97677133f1c266ffbdbd25a3cfedb8f263fc7e3715ac1bc0c88b8d963c2ae224e71c4a53d4436ae2ea49447bcc0499a92a662e29080f1093a00a637745f3ed
|
7
|
+
data.tar.gz: d80f260c6f3261eb3cc0ff6db2eacc0ee9613a7e5f35ab248f1dc12a346ba722a24ef5717a0bcca02138dca401ca84d0fa3283274ec9466f8ad0d464b400e54f
|
data/.travis.yml
CHANGED
@@ -23,6 +23,9 @@ matrix:
|
|
23
23
|
script: "bundle exec rspec spec/activerecord_spec.rb"
|
24
24
|
- env: "activerecord=4.2.0"
|
25
25
|
script: "bundle exec rspec spec/activerecord_spec.rb"
|
26
|
+
- rvm: 2.3.1
|
27
|
+
env: "activerecord=5.0.0"
|
28
|
+
script: "bundle exec rspec spec/activerecord_spec.rb"
|
26
29
|
allow_failures:
|
27
30
|
- env: "activerecord=3.2.21"
|
28
31
|
- env: "activerecord=4.2.0"
|
data/em-synchrony.gemspec
CHANGED
@@ -41,7 +41,7 @@ module ActiveRecord
|
|
41
41
|
include EM::Synchrony::ActiveRecord::Client
|
42
42
|
end
|
43
43
|
|
44
|
-
if ::ActiveRecord
|
44
|
+
if Gem::Version.new(::ActiveRecord::VERSION::STRING) >= Gem::Version.new('4.2')
|
45
45
|
require 'em-synchrony/activerecord_4_2'
|
46
46
|
include EM::Synchrony::ActiveRecord::Adapter_4_2
|
47
47
|
else
|
@@ -7,9 +7,17 @@ require 'em-synchrony/thread'
|
|
7
7
|
module ActiveRecord
|
8
8
|
module ConnectionAdapters
|
9
9
|
class ConnectionPool
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
if Gem::Version.new(::ActiveRecord::VERSION::STRING) >= Gem::Version.new('5.0')
|
11
|
+
def connection
|
12
|
+
_fibered_mutex.synchronize do
|
13
|
+
@thread_cached_conns[connection_cache_key(Thread.current)] ||= checkout
|
14
|
+
end
|
15
|
+
end
|
16
|
+
else
|
17
|
+
def connection
|
18
|
+
_fibered_mutex.synchronize do
|
19
|
+
@reserved_connections[current_connection_id] ||= checkout
|
20
|
+
end
|
13
21
|
end
|
14
22
|
end
|
15
23
|
|
data/lib/em-synchrony/kernel.rb
CHANGED
@@ -10,18 +10,18 @@ module Kernel
|
|
10
10
|
end
|
11
11
|
|
12
12
|
# Monkey-patch
|
13
|
-
def sleep(
|
13
|
+
def sleep(*args)
|
14
14
|
if Kernel.em_synchrony_sleep_hook &&
|
15
15
|
EM.reactor_thread? &&
|
16
16
|
!Thread.current[:em_synchrony_sleep_hook_called]
|
17
17
|
begin
|
18
18
|
Thread.current[:em_synchrony_sleep_hook_called] = true
|
19
|
-
Kernel.em_synchrony_sleep_hook.call(
|
19
|
+
Kernel.em_synchrony_sleep_hook.call(args[0])
|
20
20
|
ensure
|
21
21
|
Thread.current[:em_synchrony_sleep_hook_called] = false
|
22
22
|
end
|
23
23
|
else
|
24
|
-
orig_sleep(
|
24
|
+
orig_sleep(*args)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
data/spec/activerecord_spec.rb
CHANGED
@@ -14,6 +14,18 @@ describe EventMachine::Synchrony do
|
|
14
14
|
EM::Synchrony.on_sleep { fail 'should not happen' }
|
15
15
|
expect { sleep(0.01) }.not_to raise_error
|
16
16
|
end
|
17
|
+
|
18
|
+
it 'works when calling with no arguments' do
|
19
|
+
t = Thread.new do
|
20
|
+
expect { sleep }.to_not raise_error
|
21
|
+
end
|
22
|
+
while t.status
|
23
|
+
if t.status == 'sleep'
|
24
|
+
t.run
|
25
|
+
end
|
26
|
+
end
|
27
|
+
t.join
|
28
|
+
end
|
17
29
|
context 'with synchrony in another thread'do
|
18
30
|
before do
|
19
31
|
@thread = Thread.new do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: em-synchrony
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Grigorik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eventmachine
|
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
123
|
rubyforge_project:
|
124
|
-
rubygems_version: 2.
|
124
|
+
rubygems_version: 2.5.1
|
125
125
|
signing_key:
|
126
126
|
specification_version: 4
|
127
127
|
summary: Fiber aware EventMachine libraries
|
@@ -155,4 +155,3 @@ test_files:
|
|
155
155
|
- spec/thread_spec.rb
|
156
156
|
- spec/timer_spec.rb
|
157
157
|
- spec/widgets.sql
|
158
|
-
has_rdoc:
|