msgr 0.13.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/msgr/test_pool.rb +44 -0
- data/lib/msgr/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f09325407644d7b71c70a7b6815d981bd3640f09
|
4
|
+
data.tar.gz: 5a80dee22396644935fa18a3bec0f26b0a23b223
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 659863ef2373f2305081293b59ced345169f653afd8cc0a1a405f233291983b58e480ef3428d60b205a37a10690a2e8ed715bff6f99220e1d8ceca6b31508a09
|
7
|
+
data.tar.gz: bb93d514a3a07783a8a19bf8975020124f7d80a068f3c7598cf4e99608603677a1e67a6a7d5ab0bd0f3a41d2a3c2958b282802f8eeac9d9e7340a70cf21f0fb5
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
module Msgr
|
2
|
+
class TestPool
|
3
|
+
def initialize(*)
|
4
|
+
@mutex = Mutex.new
|
5
|
+
@queue = []
|
6
|
+
end
|
7
|
+
|
8
|
+
def post(*args, &block)
|
9
|
+
@mutex.synchronize { @queue << [block, args] }
|
10
|
+
end
|
11
|
+
|
12
|
+
def run(timeout: 5, count: 1)
|
13
|
+
Timeout.timeout(timeout) do
|
14
|
+
while count > 0
|
15
|
+
@mutex.synchronize do
|
16
|
+
if (item = @queue.pop)
|
17
|
+
item[0].call(*item[1])
|
18
|
+
|
19
|
+
count -= 1
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def reset
|
27
|
+
@queue.clear
|
28
|
+
end
|
29
|
+
|
30
|
+
class << self
|
31
|
+
def new(*args)
|
32
|
+
@instance ||= super(*args)
|
33
|
+
end
|
34
|
+
|
35
|
+
def run(*args)
|
36
|
+
new.run(*args)
|
37
|
+
end
|
38
|
+
|
39
|
+
def reset
|
40
|
+
@instance ? @instance.reset : nil
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/msgr/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: msgr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Graichen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- lib/msgr/railtie.rb
|
103
103
|
- lib/msgr/route.rb
|
104
104
|
- lib/msgr/routes.rb
|
105
|
+
- lib/msgr/test_pool.rb
|
105
106
|
- lib/msgr/version.rb
|
106
107
|
- msgr.gemspec
|
107
108
|
- scripts/simple_test.rb
|
@@ -182,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
183
|
version: '0'
|
183
184
|
requirements: []
|
184
185
|
rubyforge_project:
|
185
|
-
rubygems_version: 2.
|
186
|
+
rubygems_version: 2.5.1
|
186
187
|
signing_key:
|
187
188
|
specification_version: 4
|
188
189
|
summary: 'Msgr: Rails-like Messaging Framework'
|