solid_cable 3.0.4 → 3.0.5

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
  SHA256:
3
- metadata.gz: 8c170646d1e8ca3c96edceaf9675ee554eb181229d3e61abff68746e07ecd061
4
- data.tar.gz: ec9c141f177cb5e4c52b5ff8e2b0c915e048a892a47a8d50a854fe708a9a556e
3
+ metadata.gz: 5ff4e7b967cec58b0387f709a050e30db6a5d0223f070a63d878242877780c49
4
+ data.tar.gz: b3ff5a3c70b6594075e311b16ab165bce984a0eb41f1c9be2c2a34e23eccc738
5
5
  SHA512:
6
- metadata.gz: 225dcdba255693a45f6c1e8fd33982b27a4a75fc70ba6da64275aecf3140c819d5a0ef49d88c37de92318483783dac0a9a19e77c7be79efdc8403d42a8413162
7
- data.tar.gz: 32bec49c5542d5dff12a14b2ed041644dc6e73894618f85d45eaad6ae8dab1fa1177a9029abc37ec04a1c24285b4d39d7ebd6e1c58f60cdff03fa75fa7ab24d6
6
+ metadata.gz: 771044684f961dad0116e7769ac429d06ce613d5779809818a81146a585ef4ffeda081533031a7c90767e6e0cd913478b2ffb3117e1d9886bae48d6b9e6c9459
7
+ data.tar.gz: 18b65de8a357d40af82bbf0d749ca43dcd864fe8e06b074701c97cbdf37eef3e6aa5f36178b51c853612d14688d1d51d99c395ba894171d73f097a18112daeb0
@@ -50,16 +50,22 @@ module ActionCable
50
50
  end
51
51
 
52
52
  def listen
53
- while running?
53
+ loop do
54
+ break unless running?
55
+
54
56
  with_polling_volume { broadcast_messages }
55
57
 
56
- sleep ::SolidCable.polling_interval
58
+ interruptible_sleep ::SolidCable.polling_interval
57
59
  end
58
60
  end
59
61
 
60
62
  def shutdown
61
63
  self.running = false
62
- Thread.pass while thread.alive?
64
+ wake_up
65
+
66
+ ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
67
+ thread&.join
68
+ end
63
69
  end
64
70
 
65
71
  def add_channel(channel, on_success)
@@ -112,6 +118,37 @@ module ActionCable
112
118
  yield
113
119
  end
114
120
  end
121
+
122
+ def wake_up
123
+ interrupt
124
+ end
125
+
126
+ SELF_PIPE_BLOCK_SIZE = 11
127
+
128
+ def interrupt
129
+ self_pipe[:writer].write_nonblock(".")
130
+ rescue Errno::EAGAIN, Errno::EINTR
131
+ # Ignore writes that would block and retry
132
+ # if another signal arrived while writing
133
+ retry
134
+ end
135
+
136
+ def interruptible_sleep(time)
137
+ if time > 0 && self_pipe[:reader].wait_readable(time)
138
+ loop { self_pipe[:reader].read_nonblock(SELF_PIPE_BLOCK_SIZE) }
139
+ end
140
+ rescue Errno::EAGAIN, Errno::EINTR
141
+ end
142
+
143
+ # Self-pipe for signal-handling (http://cr.yp.to/docs/selfpipe.html)
144
+ def self_pipe
145
+ @self_pipe ||= create_self_pipe
146
+ end
147
+
148
+ def create_self_pipe
149
+ reader, writer = IO.pipe
150
+ { reader: reader, writer: writer }
151
+ end
115
152
  end
116
153
  end
117
154
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidCable
4
- VERSION = "3.0.4"
4
+ VERSION = "3.0.5"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solid_cable
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.4
4
+ version: 3.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Pezza
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-06 00:00:00.000000000 Z
11
+ date: 2024-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord