simplex-chat 0.6.0 → 0.6.1

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
  SHA256:
3
- metadata.gz: 0b49dea10199c71c10df356701b53087eda1e8aeb5c31348e39a62032280d96b
4
- data.tar.gz: e97b4de663eb4abe3aac556b6f8a1b2cf1dcce1d37b2ebfdfc645a7b8e9c05a4
3
+ metadata.gz: 1085de134ea131845256d9109e043629b6f83ab59adf94625c89287272c9966a
4
+ data.tar.gz: e2a1ac6403338b1cc07238d4dc6a2cdb15992a5e938b3df04c98d72d7cce3a93
5
5
  SHA512:
6
- metadata.gz: c2c78755a44732f0b2ab43a080981d4f332c414e2080ff8e4d8ddf76a6af8ed53a0e6c5699561df33b0d8e9d713c92774c1dbff75cc60809adb4ff463f10af8f
7
- data.tar.gz: 70eb7367381d1442ed72ff4ae92ed7d876d99e1d3d506bd4da9eafa833f7e1e32c814bec37e052ca9c0b932f726bba59668459de646fac20b004fff14f0ced15
6
+ metadata.gz: 516773178824c494adaa70bef60b323774c8775456eeef1de33ca3bc2131073808d85db998ebade717254286374db2f25b8bec2ba4fd903502b229a70ecc2467
7
+ data.tar.gz: 9c4848683f657f145538979603d2d5edfa83e32aaf030b6422b5d60ca38613ff8a517abd30f800c508744e255f48d4a172fa4297e2d9ae7d2f55b6ef948db5e1
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SimpleXChat
4
- VERSION = "0.6.0"
4
+ VERSION = "0.6.1"
5
5
  end
data/lib/simplex-chat.rb CHANGED
@@ -110,7 +110,13 @@ module SimpleXChat
110
110
  # a chat message queue to insert one or
111
111
  # more messages at a time, but poll just
112
112
  # one at a time
113
- return @chat_message_queue.pop if not @chat_message_queue.empty?
113
+ # NOTE: We use non-blocking pop for thread safety
114
+ begin
115
+ chat_msg = @chat_message_queue.pop(true)
116
+ return chat_msg
117
+ rescue ThreadError
118
+ @logger.debug("Chat message queue is empty, waiting for new messages...")
119
+ end
114
120
 
115
121
  loop do
116
122
  msg = next_message
@@ -135,13 +141,20 @@ module SimpleXChat
135
141
  end
136
142
 
137
143
  @chat_message_queue.push chat_message
144
+ @logger.debug("Chat message pushed to queue: #{chat_message}")
138
145
  end
139
146
 
140
147
  # NOTE: Even after parsing the messages, the
141
148
  # chat message queue can be empty because
142
149
  # all the messages are too old, so we have
143
150
  # to check again
144
- return @chat_message_queue.pop if not @chat_message_queue.empty?
151
+ begin
152
+ chat_msg = @chat_message_queue.pop(true)
153
+ @logger.debug("Chat message popped from queue")
154
+ return chat_msg
155
+ rescue ThreadError
156
+ @logger.debug("Chat message queue is still empty, waiting for new messages...")
157
+ end
145
158
  end
146
159
 
147
160
  nil
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplex-chat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - rdbo