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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6ea7c27ccb28ae6e7707322abba88d6fa1aca484
4
- data.tar.gz: 8bf200c3679a9b723921c1bb559e39b9c7fa3cc6
3
+ metadata.gz: fdf1716e96ece289c24b2259f51862f8e0b0f847
4
+ data.tar.gz: 9def49fb3291dc30d43fd135e13ea4475f92c01b
5
5
  SHA512:
6
- metadata.gz: b8439c232a0d8389bcb7bf4dc22dbe2cfb1cce26bb3434b09d508fcfaec219c9926390406827a23e766ebde4620bf2d5beb5af45018c4098747497abb6bba8cf
7
- data.tar.gz: 7e1d88c1ca35cd09e289468444fc72615f1f9843cb662b99fcc50cd8093c05caeca3066a9613d601a31618bf7568638650a0ab60d5521b20a89a126780a6f638
6
+ metadata.gz: 203c99df1e7b83eff110d5dcfed5f607fbd7ff681f844b10de394b7c9fb9ed1d29c53a665500ef55d2e4c8272546e7ce7270d9a63fd7add7f01a92f351daced6
7
+ data.tar.gz: bc35ea931662f4076c35f8e74df08739a149875e86d50cc3fe146fe458f07c640ba020a3e79eccb72680303980f72c36a0d102afcf45f02193432be819515c5a
@@ -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 EMSpec # :nodoc:
14
- class << self
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 EMSpec.context_thread == Thread.current
51
- super
52
- else
53
- EM::run do
54
- EM::error_handler do |err|
55
- ::Bacon::store_error(err, "(EM Loop)")
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(:include, EMSpec)
20
+
21
+ Context.send(:prepend, Threaded)
76
22
  end
@@ -1,3 +1,3 @@
1
1
  module Bacon
2
- VERSION = "1.7.0"
2
+ VERSION = "1.7.1"
3
3
  end
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.0
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-10-16 00:00:00.000000000 Z
11
+ date: 2018-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: term-ansicolor