philiprehberger-task_queue 0.6.0 → 0.7.1
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/CHANGELOG.md +12 -1
- data/README.md +3 -0
- data/lib/philiprehberger/task_queue/queue.rb +10 -0
- data/lib/philiprehberger/task_queue/version.rb +1 -1
- data/lib/philiprehberger/task_queue/worker.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5bd60112f6cfee945ef38be345d06ee98eb67f8cf41c58130d878806512f6459
|
|
4
|
+
data.tar.gz: 0def7843e02bfa558090f72aa9deee01c9383f5dbc2bbdfa7d8864f3b0e41cef
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e80d762e3fb12eed38918bc931c8b057052800938746ac83d35b86343e129e1aec1ab41a6f85f971ddf7f96fdcba181fd0e9d69971e347cc2b50ee371bb25340
|
|
7
|
+
data.tar.gz: 882bd1d57135f0e52e55dea6bc6a8660e443c4061e0e629dba35ae0ffff9ea43e0ce61848c2c939d4267452def0be6a546584a79219b1102dedf208f9216843d
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.7.1] - 2026-06-14
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- Added package card image to README
|
|
14
|
+
- Added YARD doc comments to Worker public methods
|
|
15
|
+
- Cleaned up CHANGELOG formatting
|
|
16
|
+
|
|
17
|
+
## [0.7.0] - 2026-05-13
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
- `Queue#busy?` — predicate returning `true` when there are pending tasks or in-flight tasks; convenient inverse of "idle" for callers polling without going through `#stats`.
|
|
21
|
+
|
|
10
22
|
## [0.6.0] - 2026-05-07
|
|
11
23
|
|
|
12
24
|
### Added
|
|
@@ -57,7 +69,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
57
69
|
- Fix License section format
|
|
58
70
|
- Sync gemspec summary with README
|
|
59
71
|
|
|
60
|
-
|
|
61
72
|
## [0.2.8] - 2026-03-24
|
|
62
73
|
|
|
63
74
|
### Fixed
|
data/README.md
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
[](https://rubygems.org/gems/philiprehberger-task_queue)
|
|
5
5
|
[](https://github.com/philiprehberger/rb-task-queue/commits/main)
|
|
6
6
|
|
|
7
|
+

|
|
8
|
+
|
|
7
9
|
In-process async job queue with concurrency control
|
|
8
10
|
|
|
9
11
|
## Requirements
|
|
@@ -205,6 +207,7 @@ queue.shutdown(timeout: 5)
|
|
|
205
207
|
| `#<<(callable)` | `callable` — any object responding to `#call` | `self` | Alias for `#push`; convenient for lambdas and procs |
|
|
206
208
|
| `#size` | _(none)_ | `Integer` | Number of pending (not yet started) tasks |
|
|
207
209
|
| `#empty?` | _(none)_ | `Boolean` | Whether there are no pending tasks waiting to be started |
|
|
210
|
+
| `#busy?` | _(none)_ | `Boolean` | Whether the queue has any pending tasks or in-flight tasks |
|
|
208
211
|
| `#running?` | _(none)_ | `Boolean` | Whether the queue is accepting new tasks |
|
|
209
212
|
| `#shutdown(timeout:)` | `timeout` — seconds to wait for workers (Numeric, default `30`) | `nil` | Signal workers to stop, drain remaining tasks, join threads up to `timeout` seconds |
|
|
210
213
|
| `#on_complete(&block)` | `&block` — callback receiving `(result)` | `self` | Register a callback invoked after each successful task completion with the task's return value |
|
|
@@ -173,6 +173,16 @@ module Philiprehberger
|
|
|
173
173
|
@mutex.synchronize { @tasks.empty? }
|
|
174
174
|
end
|
|
175
175
|
|
|
176
|
+
# Whether the queue has any pending tasks or any in-flight tasks.
|
|
177
|
+
#
|
|
178
|
+
# Convenient inverse of "idle" for callers polling without going
|
|
179
|
+
# through +stats+. Equivalent to: +!empty? || in_flight > 0+.
|
|
180
|
+
#
|
|
181
|
+
# @return [Boolean]
|
|
182
|
+
def busy?
|
|
183
|
+
@mutex.synchronize { !@tasks.empty? || @stats[:in_flight].positive? }
|
|
184
|
+
end
|
|
185
|
+
|
|
176
186
|
# Whether the queue is accepting new tasks.
|
|
177
187
|
#
|
|
178
188
|
# @return [Boolean]
|
|
@@ -20,10 +20,17 @@ module Philiprehberger
|
|
|
20
20
|
@thread = Thread.new { run }
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
# Signal the worker to stop after its current task completes.
|
|
24
|
+
#
|
|
25
|
+
# @return [void]
|
|
23
26
|
def stop
|
|
24
27
|
@running = false
|
|
28
|
+
nil
|
|
25
29
|
end
|
|
26
30
|
|
|
31
|
+
# Whether the underlying worker thread is still alive.
|
|
32
|
+
#
|
|
33
|
+
# @return [Boolean]
|
|
27
34
|
def alive?
|
|
28
35
|
@thread&.alive? || false
|
|
29
36
|
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
|
+
version: 0.7.1
|
|
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-
|
|
11
|
+
date: 2026-06-15 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.
|