grumlin 0.10.0 → 0.10.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
  SHA256:
3
- metadata.gz: 360fd18e170020dfe02e879e9e20e29a958de425e20dd3217c70c1317ae87850
4
- data.tar.gz: ec7c3b496802689d0bd5cd82b9eba303ec4b5f60deb993f0fe48bf446d69004a
3
+ metadata.gz: 2306eba516eebd5d53ac7e8e77acd5d7b2fcb7ad3579e9abc734210aec20ce29
4
+ data.tar.gz: ebd72733ea3f6ac4554044a00aac252f6a14997664a7b95ebdba01d082e4c8cd
5
5
  SHA512:
6
- metadata.gz: 79e60622d3c58154b13939880a394062f96fdade9eb5eafbe2ed13b040ad2d4749d134e4cc2ad5ba18c48872ed04d71d3ef833525e16765b774fb489cfb24f95
7
- data.tar.gz: 4a00526ab10dd4c90a1c83f5fb94a572152b14bd5884be096605d6a1acf8b80c8143ab24a766b9ad25b5d2b93b78f848bce94784c13bd3b1afbdfa6567a24070
6
+ metadata.gz: bda5181c00cabc8d69fdaa891a81943527dabfaa69ce70babbba6c1f11efc83b6f942d23d6aaf792d580f842ca7f64971986def6e1cfc1e6d4d3626da05efa1b
7
+ data.tar.gz: 212fbac76d50dfe281e574604ffbb82e8008937d777c279575a05468ee0f063faa6f0a8fa1417e8ea40e96f72b1b9f1f61c9e881e7c9b800d25964ce3ad7932a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grumlin (0.10.0)
4
+ grumlin (0.10.1)
5
5
  async-pool (~> 0.3)
6
6
  async-websocket (~> 0.19)
7
7
  oj (~> 3.12)
@@ -64,7 +64,7 @@ GEM
64
64
  nio4r (2.5.8)
65
65
  nokogiri (1.11.7-x86_64-linux)
66
66
  racc (~> 1.4)
67
- oj (3.13.4)
67
+ oj (3.13.6)
68
68
  overcommit (0.57.0)
69
69
  childprocess (>= 0.6.3, < 5)
70
70
  iniparse (~> 1.4)
data/lib/grumlin/step.rb CHANGED
@@ -10,8 +10,18 @@ module Grumlin
10
10
  end
11
11
 
12
12
  def next
13
- @enum ||= toList.to_enum
14
- @enum.next
13
+ to_enum.next
14
+ end
15
+
16
+ def hasNext # rubocop:disable Naming/MethodName
17
+ to_enum.peek
18
+ true
19
+ rescue StopIteration
20
+ false
21
+ end
22
+
23
+ def to_enum
24
+ @to_enum ||= toList.to_enum
15
25
  end
16
26
 
17
27
  def toList
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Grumlin
4
- VERSION = "0.10.0"
4
+ VERSION = "0.10.1"
5
5
  end
data/lib/grumlin.rb CHANGED
@@ -104,16 +104,10 @@ module Grumlin
104
104
  @client_concurrency = 5
105
105
  @client_factory = ->(url, parent) { Grumlin::Client.new(url, parent: parent) }
106
106
  end
107
-
108
- def default_pool
109
- @default_pool ||= Async::Pool::Controller.new(Grumlin::Client::PoolResource, limit: pool_size)
110
- end
111
-
112
- def reset!
113
- @default_pool = nil
114
- end
115
107
  end
116
108
 
109
+ @pool_mutex = Mutex.new
110
+
117
111
  class << self
118
112
  def configure
119
113
  yield config
@@ -124,14 +118,26 @@ module Grumlin
124
118
  end
125
119
 
126
120
  def default_pool
127
- config.default_pool
121
+ if Thread.current.thread_variable_get(:grumlin_default_pool)
122
+ return Thread.current.thread_variable_get(:grumlin_default_pool)
123
+ end
124
+
125
+ @pool_mutex.synchronize do
126
+ Thread.current.thread_variable_set(:grumlin_default_pool,
127
+ Async::Pool::Controller.new(Grumlin::Client::PoolResource,
128
+ limit: config.pool_size))
129
+ end
128
130
  end
129
131
 
130
132
  def close
131
- default_pool.wait while default_pool.busy?
132
-
133
- default_pool.close
134
- config.reset!
133
+ return if Thread.current.thread_variable_get(:grumlin_default_pool).nil?
134
+
135
+ @pool_mutex.synchronize do
136
+ pool = Thread.current.thread_variable_get(:grumlin_default_pool)
137
+ pool.wait while pool.busy?
138
+ pool.close
139
+ Thread.current.thread_variable_set(:grumlin_default_pool, nil)
140
+ end
135
141
  end
136
142
  end
137
143
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grumlin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gleb Sinyavskiy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-09 00:00:00.000000000 Z
11
+ date: 2021-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-pool