philiprehberger-task_queue 0.4.2 → 0.5.0

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: 9f4e9b0ae4aaef03d903590f90278ed497bf0a4a39b76ee2a7f982d2c949e6c8
4
- data.tar.gz: 5aa3e3eed6e165c88535e59bb7309d98e6790fbcd055faaf16ecff8daef7731e
3
+ metadata.gz: 9e95b1aa86d2dd6d24bffa365e89a42a94b3e667da82884145503f3f40dcd27c
4
+ data.tar.gz: ca709893092da51f536a6cf209b986f6e085fea9b2cd391f9d705fbc3ab7267c
5
5
  SHA512:
6
- metadata.gz: dea4e36934d59796510506c3ece4af9bbbe1bf0307eeaa8c79fc6421f187b700b79c4b61d439e927e9720ee483f75cf0b6cedcd84e642a03a1352814efbdcacb
7
- data.tar.gz: b7aafb9cccc93e6e753720c194300f6caa2b7407c080949fea77a985ab4d40ac3c8033535cc3485e124359bfc75ad6f1d3d6d5b40dec9cac5560f68e14c379af
6
+ metadata.gz: 998d63c445066bb5b913b9b652121775b620d30175b6f354cc22d071eec98f9818f6bac9ca79f1b02185da57d5401ac44327ca459e588fdbe3fc7ea293bd1e91
7
+ data.tar.gz: 56eeafdb0b968a163a69b709eafaf1ca934e543eaeb45d532a4f730333bca83644f3ad808327b1c071056d9870a2cf4b0018b44849a4bd298c256002b58acd33
data/CHANGELOG.md CHANGED
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.5.0] - 2026-04-19
11
+
12
+ ### Added
13
+ - `Queue#stats_reset!` — atomically zero the `completed` and `failed` counters while leaving pending, in-flight, workers, and callbacks untouched; useful for per-interval metrics
14
+
10
15
  ## [0.4.2] - 2026-04-08
11
16
 
12
17
  ### Changed
data/README.md CHANGED
@@ -140,6 +140,16 @@ puts "Cleared #{cleared} tasks"
140
140
  queue.shutdown(timeout: 5)
141
141
  ```
142
142
 
143
+ ### Reset counters
144
+
145
+ ```ruby
146
+ queue = Philiprehberger::TaskQueue.new(concurrency: 4)
147
+ 10.times { queue.push { do_work } }
148
+ queue.drain
149
+ queue.stats_reset!
150
+ queue.stats[:completed] # => 0
151
+ ```
152
+
143
153
  ### FIFO ordering guarantees
144
154
 
145
155
  Tasks are stored in an internal array and dequeued in FIFO order. When `concurrency` is `1`, tasks execute strictly in the order they were pushed. With higher concurrency, dequeue order is still FIFO but tasks may complete out of order depending on individual execution time.
@@ -203,6 +213,7 @@ queue.shutdown(timeout: 5)
203
213
  | `#resume` | _(none)_ | `self` | Resume a paused queue, waking workers to continue processing |
204
214
  | `#paused?` | _(none)_ | `Boolean` | Whether the queue is currently paused |
205
215
  | `#clear` | _(none)_ | `Integer` | Remove all pending tasks and return the number cleared |
216
+ | `#stats_reset!` | _(none)_ | `self` | Atomically zero the `completed` and `failed` counters while leaving pending, in-flight, workers, and callbacks untouched |
206
217
 
207
218
  ## Development
208
219
 
@@ -100,6 +100,21 @@ module Philiprehberger
100
100
  end
101
101
  end
102
102
 
103
+ # Atomically zero the +completed+ and +failed+ counters.
104
+ #
105
+ # Leaves +pending+, +in_flight+, worker threads, and registered callbacks
106
+ # untouched. Useful for resetting metrics between reporting intervals
107
+ # without shutting down the pool.
108
+ #
109
+ # @return [self]
110
+ def stats_reset!
111
+ @mutex.synchronize do
112
+ @stats[:completed] = 0
113
+ @stats[:failed] = 0
114
+ end
115
+ self
116
+ end
117
+
103
118
  # Block until all pending tasks are complete without shutting down.
104
119
  #
105
120
  # @param timeout [Numeric] seconds to wait before returning
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Philiprehberger
4
4
  module TaskQueue
5
- VERSION = '0.4.2'
5
+ VERSION = '0.5.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: philiprehberger-task_queue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Rehberger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-04-09 00:00:00.000000000 Z
11
+ date: 2026-04-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A lightweight, zero-dependency, thread-safe in-process async job queue
14
14
  with configurable concurrency for Ruby applications.