schmurfy-bacon 1.6.4 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dcb5050ddc789d1701bcaa4cc59876c6682bf543
4
- data.tar.gz: a7c957e1d0f290bc56bd3052bcd7608c16e4291e
3
+ metadata.gz: 6ea7c27ccb28ae6e7707322abba88d6fa1aca484
4
+ data.tar.gz: 8bf200c3679a9b723921c1bb559e39b9c7fa3cc6
5
5
  SHA512:
6
- metadata.gz: b4bdf591f249b011a10f30723628eea564097e48a82c65cd6a4e48c0c105c725a32c825819530880d8a7c65ca69d2b2a3c7dc7898f09879311688c751051deea
7
- data.tar.gz: cafad2ea51723e3e961257df8f772d734acbe2ce61235f6fba011f49d8af303fdb023f645f5e7cbab8a7cc2250846668d484a210aef6894db8a8f1af5bbe3148
6
+ metadata.gz: b8439c232a0d8389bcb7bf4dc22dbe2cfb1cce26bb3434b09d508fcfaec219c9926390406827a23e766ebde4620bf2d5beb5af45018c4098747497abb6bba8cf
7
+ data.tar.gz: 7e1d88c1ca35cd09e289468444fc72615f1f9843cb662b99fcc50cd8093c05caeca3066a9613d601a31618bf7568638650a0ab60d5521b20a89a126780a6f638
@@ -0,0 +1,76 @@
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
+ 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
+
49
+ 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
66
+ end
67
+
68
+ end
69
+
70
+ end
71
+ end
72
+
73
+ end
74
+
75
+ Context.send(:include, EMSpec)
76
+ end
data/lib/bacon/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bacon
2
- VERSION = "1.6.4"
2
+ VERSION = "1.7.0"
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.6.4
4
+ version: 1.7.0
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-02-19 00:00:00.000000000 Z
11
+ date: 2018-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: term-ansicolor
@@ -68,6 +68,7 @@ files:
68
68
  - lib/bacon.rb
69
69
  - lib/bacon/ext/async.rb
70
70
  - lib/bacon/ext/em.rb
71
+ - lib/bacon/ext/em_threads.rb
71
72
  - lib/bacon/ext/http.rb
72
73
  - lib/bacon/ext/mocha.rb
73
74
  - lib/bacon/ext/no_gc.rb