schmurfy-bacon 1.7.0 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bacon/ext/em_threads.rb +13 -67
- data/lib/bacon/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fdf1716e96ece289c24b2259f51862f8e0b0f847
|
4
|
+
data.tar.gz: 9def49fb3291dc30d43fd135e13ea4475f92c01b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 203c99df1e7b83eff110d5dcfed5f607fbd7ff681f844b10de394b7c9fb9ed1d29c53a665500ef55d2e4c8272546e7ce7270d9a63fd7add7f01a92f351daced6
|
7
|
+
data.tar.gz: bc35ea931662f4076c35f8e74df08739a149875e86d50cc3fe146fe458f07c640ba020a3e79eccb72680303980f72c36a0d102afcf45f02193432be819515c5a
|
data/lib/bacon/ext/em_threads.rb
CHANGED
@@ -1,76 +1,22 @@
|
|
1
|
-
|
2
|
-
require 'thread'
|
3
|
-
require 'eventmachine'
|
4
|
-
|
5
|
-
#
|
6
|
-
# This module allows you to run your specs inside an eventmachine loop
|
7
|
-
# check examples/em_spec.rb for usage.
|
8
|
-
#
|
9
|
-
# Be aware that it does not work like the em-spec gem, no timeout error will
|
10
|
-
# ever be raised.
|
11
|
-
#
|
12
1
|
module Bacon
|
13
|
-
module
|
14
|
-
|
15
|
-
attr_accessor :context_thread
|
16
|
-
end
|
17
|
-
|
18
|
-
def wakeup
|
19
|
-
# this should be enough but for some reason the reactor
|
20
|
-
# idles for 20 seconds on EM::stop before really exiting
|
21
|
-
# @waiting_thread.resume
|
22
|
-
|
23
|
-
if @waiting_thread
|
24
|
-
EM::next_tick { @waiting_thread.wakeup }
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def wait(timeout = 0.1, &block)
|
29
|
-
@waiting_thread = Thread.current
|
30
|
-
EM::cancel_timer(@timeout)
|
31
|
-
@timeout = EM::add_timer(timeout, &method(:wakeup))
|
32
|
-
|
33
|
-
sleep
|
34
|
-
|
35
|
-
@waiting_thread = nil
|
36
|
-
|
37
|
-
block.call if block
|
38
|
-
end
|
39
|
-
|
40
|
-
def done
|
41
|
-
EM.cancel_timer(@timeout)
|
42
|
-
wakeup
|
43
|
-
end
|
44
|
-
|
45
|
-
def new_thread(&block)
|
46
|
-
Thread.new(&block)
|
47
|
-
end
|
48
|
-
|
2
|
+
module Threaded
|
3
|
+
|
49
4
|
def run(*)
|
50
|
-
if
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
::
|
56
|
-
end
|
57
|
-
|
58
|
-
new_thread do
|
59
|
-
EMSpec.context_thread = Thread.current
|
60
|
-
begin
|
61
|
-
super
|
62
|
-
EM::stop_event_loop
|
63
|
-
ensure
|
64
|
-
EMSpec.context_thread = nil
|
65
|
-
end
|
5
|
+
if Thread.main == Thread.current
|
6
|
+
EM.next_tick do
|
7
|
+
Thread.new do
|
8
|
+
sleep(0.1)
|
9
|
+
super
|
10
|
+
EM::stop_event_loop()
|
66
11
|
end
|
67
|
-
|
12
|
+
|
68
13
|
end
|
69
|
-
|
14
|
+
else
|
15
|
+
super
|
70
16
|
end
|
71
17
|
end
|
72
18
|
|
73
19
|
end
|
74
|
-
|
75
|
-
Context.send(:
|
20
|
+
|
21
|
+
Context.send(:prepend, Threaded)
|
76
22
|
end
|
data/lib/bacon/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schmurfy-bacon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christian Neukirchen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: term-ansicolor
|