lowevent 0.8.12 → 0.8.13
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 +4 -4
- data/lib/pool/event_pool.rb +7 -4
- data/lib/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 32b73c3799451315006e5b139bfbc6f18957acc05825a39ad67d0646bbf1c2e5
|
|
4
|
+
data.tar.gz: 4d6675e9d725f3025cbe0556330fbe350e92a83455c61e2700ed52bb4e2498ab
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ea2d842804d1a9af242d081c057a9fdb6130fc6d58227c9398d9aadbd91e81d8518ada8aca6e2948fde1121d01e456d72ce601ff46fc3d3043e72c2e79ad1e86
|
|
7
|
+
data.tar.gz: 4c5feca4a64ae7edd11a783506aaad864d69e8167ca5134fc68d019a86dd54ac4463a87549e0c7914b87b8b5d996d8076643c037274c6006ea2657a05eeaed36
|
data/lib/pool/event_pool.rb
CHANGED
|
@@ -13,6 +13,8 @@ module Low
|
|
|
13
13
|
|
|
14
14
|
BUFFER_SIZE = 100
|
|
15
15
|
KEPT_APART_SIZE = 20
|
|
16
|
+
REQUEST_COUNT_BITS = 32
|
|
17
|
+
REQUEST_COUNT_MASK = (1 << REQUEST_COUNT_BITS) - 1
|
|
16
18
|
|
|
17
19
|
# The app's trees, and how many events run each second, however their tree is kept.
|
|
18
20
|
attr_reader :event_trees, :action_rate
|
|
@@ -22,7 +24,6 @@ module Low
|
|
|
22
24
|
@event_trees = Support::PoolHash.new(BUFFER_SIZE)
|
|
23
25
|
@kept_apart_trees = Support::PoolHash.new(KEPT_APART_SIZE)
|
|
24
26
|
@request_counts = Support::PoolHash.new(BUFFER_SIZE)
|
|
25
|
-
@request_ids = Support::PoolHash.new(BUFFER_SIZE) # Each fiber's current request ID, made once for all its events.
|
|
26
27
|
@kept_apart = nil
|
|
27
28
|
end
|
|
28
29
|
|
|
@@ -66,15 +67,17 @@ module Low
|
|
|
66
67
|
current_request_id(fiber_id)
|
|
67
68
|
end
|
|
68
69
|
|
|
70
|
+
# The fiber's ID and its count of requests in one Integer, as a string of them would be made for every request.
|
|
71
|
+
# A count of 0 is the fiber's events before its first request. Its count wraps after 4 billion requests, by when
|
|
72
|
+
# trees with the same ID have long left the pool.
|
|
69
73
|
def current_request_id(fiber_id)
|
|
70
|
-
|
|
74
|
+
(fiber_id << REQUEST_COUNT_BITS) | (@request_counts[fiber_id] || 0)
|
|
71
75
|
end
|
|
72
76
|
|
|
73
77
|
# Added rather than set, so only the last fibers' counts are kept, as each connection can have a fiber of its own.
|
|
74
78
|
def increment_request_counts(fiber_id:)
|
|
75
|
-
count = (@request_counts[fiber_id] || 0) + 1
|
|
79
|
+
count = ((@request_counts[fiber_id] || 0) + 1) & REQUEST_COUNT_MASK
|
|
76
80
|
@request_counts.add(fiber_id, count)
|
|
77
|
-
@request_ids.add(fiber_id, "#{fiber_id}-#{count}".freeze)
|
|
78
81
|
end
|
|
79
82
|
end
|
|
80
83
|
end
|
data/lib/version.rb
CHANGED