grammerb 1.0.6-x86_64-linux → 1.0.7-x86_64-linux

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: 4958186e26db4c717cd9f70b51954b31b48f1c2b25b6c1251501b7211375067a
4
- data.tar.gz: bf46f7dd219f4e8e43f51970e0926fc74f58e2b2ed94c4f6232b44d0bec1a0bf
3
+ metadata.gz: 29912c30c6178c1d2ce079c9aece834ec95275f86e1213948a349a55bdfb7e2a
4
+ data.tar.gz: e623de790bcf1aacd6225b1f418b480e439b62ee4257bd9ddf837c51a7c9865a
5
5
  SHA512:
6
- metadata.gz: 7899f7808cc9a2efadc12732ea981ff4fd3ab283b8236a9ed47918bef90f98b5778fa7f2a3e7fa2b91f5707deb19db384e90b0883718f20d3836ad4280732932
7
- data.tar.gz: f0b8f1f8897eecbde06fda066b942ef882b38215ded4322b93fbcb429a1718abaacef6a50e96e841b5e3fb2092e4fa69e26e25720e7cfc360fa66be43a039f36
6
+ metadata.gz: 34bbf0bcaa9841d10659e7da43d65e210c067135b32ab90c31b1a30f8b7008ff4c552c1cadb9f8452fcdac433ba07bbc4ec732e3e1093d68931fd8e908dc4989
7
+ data.tar.gz: d4c49375bb20fb16fac74d5981505366d467c73cd7f294ca2f15baa6c773e28e586e01d1ce85ec094a1b02d8e9052e49b97fce2caf010c0f236cc50722474aba
@@ -6,42 +6,28 @@ require "set"
6
6
  module Grammerb
7
7
  class HandlerPool
8
8
  def initialize(size)
9
- @size = size
10
9
  @queue = Queue.new
11
- @workers = nil
12
- @mu = Mutex.new
10
+ @workers = size.times.map do
11
+ Thread.new do
12
+ loop do
13
+ task = @queue.pop
14
+ break if task == :shutdown
15
+ task.call
16
+ rescue => e
17
+ # Error handling is inside the task block itself
18
+ end
19
+ end
20
+ end
13
21
  end
14
22
 
15
23
  def schedule(&block)
16
- ensure_started
17
24
  @queue.push(block)
18
25
  end
19
26
 
20
27
  def shutdown
21
- return unless @workers
22
28
  @workers.size.times { @queue.push(:shutdown) }
23
29
  @workers.each { |t| t.join(5) }
24
30
  end
25
-
26
- private
27
-
28
- def ensure_started
29
- return if @workers
30
- @mu.synchronize do
31
- return if @workers
32
- @workers = @size.times.map do
33
- Thread.new do
34
- loop do
35
- task = @queue.pop
36
- break if task == :shutdown
37
- task.call
38
- rescue => e
39
- # Error handling is inside the task block itself
40
- end
41
- end
42
- end
43
- end
44
- end
45
31
  end
46
32
 
47
33
  class Client
@@ -49,6 +35,7 @@ module Grammerb
49
35
 
50
36
  def initialize(api_id:, api_hash:, session: "grammerb.session", proxy: nil, logger: nil, pool_size: 20)
51
37
  @session_path = session
38
+ @native = Grammerb::Native::Client.new(api_id, api_hash, session, proxy)
52
39
  @handlers = []
53
40
  @handlers_mu = Mutex.new
54
41
  @handlers_snapshot = [].freeze
@@ -60,7 +47,6 @@ module Grammerb
60
47
  @logger = logger || default_logger
61
48
  @entity_cache = {}
62
49
  @entity_cache_mu = Mutex.new
63
- @native = Grammerb::Native::Client.new(api_id, api_hash, session, proxy)
64
50
  end
65
51
 
66
52
  # --- Connection ---
@@ -1,4 +1,4 @@
1
1
  # lib/grammerb/version.rb
2
2
  module Grammerb
3
- VERSION = "1.0.6"
3
+ VERSION = "1.0.7"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grammerb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Developer