fibre 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fibre.rb +6 -2
- data/lib/fibre/version.rb +1 -1
- data/spec/fiber_pool_spec.rb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f970c043f98fcc2801ddfe967e4f34b3530dd4df
|
4
|
+
data.tar.gz: 719b4c185bf0840bdf36b404d8240fa9e49ef543
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4f2515c15206146d75828a88b42f1b66c7aa623b850e2f53c65cb722c071f48253ce1a2c85661ad70d3915bce290e8cb79a7a463c9eee46633cf4d7e6243b59
|
7
|
+
data.tar.gz: 89eb35e13e9208a8b8ab4656b11478b64ecd308fd7b7af66af9a5224d6665997c709b5fa7942955d1b04c16ea1a2c7b1fe03f2cbca11bbd856749fb9c1a050e7
|
data/lib/fibre.rb
CHANGED
@@ -23,8 +23,8 @@ module Fibre
|
|
23
23
|
DEFAULT_POOL_QUEUE_SIZE = 1000
|
24
24
|
FIBER_POOL_THREADED = '__fiber_pool'
|
25
25
|
|
26
|
-
def
|
27
|
-
|
26
|
+
def init_pool(*a)
|
27
|
+
Thread.current[FIBER_POOL_THREADED] = make_pool(*a)
|
28
28
|
end
|
29
29
|
|
30
30
|
# Auto-initialize at first call and each thread has own fiber pool
|
@@ -36,4 +36,8 @@ module Fibre
|
|
36
36
|
Thread.current[FIBER_POOL_THREADED] = nil
|
37
37
|
pool
|
38
38
|
end
|
39
|
+
|
40
|
+
def make_pool(pool_size: DEFAULT_POOL_SIZE, pool_queue_size: DEFAULT_POOL_QUEUE_SIZE)
|
41
|
+
FiberPool.new(pool_size: pool_size, pool_queue_size: pool_queue_size)
|
42
|
+
end
|
39
43
|
end
|
data/lib/fibre/version.rb
CHANGED
data/spec/fiber_pool_spec.rb
CHANGED
@@ -13,6 +13,12 @@ describe Fibre do
|
|
13
13
|
expect(Fibre.pool.pool_queue_size).to be(1000)
|
14
14
|
end
|
15
15
|
|
16
|
+
it "initializes global pool" do
|
17
|
+
Fibre.init_pool(pool_size: 10, pool_queue_size: 900)
|
18
|
+
expect(Fibre.pool.pool_size).to be(10)
|
19
|
+
expect(Fibre.pool.pool_queue_size).to be(900)
|
20
|
+
end
|
21
|
+
|
16
22
|
it "has the root fiber" do
|
17
23
|
expect(Fibre.root).to equal(Fiber.current)
|
18
24
|
expect(Fiber.current.root?).to be true
|