upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src
diff options
context:
space:
mode:
authorNarek Shaghoyan <narekshagoyan7@gmail.com>2026-11-24 15:16:22 +0000
committerNarek Shaghoyan <narekshagoyan7@gmail.com>2026-11-24 15:16:22 +0000
commit9392bbd9e03b88fd4746f51e2fb1e7cd7b0e5b86 (patch)
tree2a2cacbac45220ef3b3246c0af4ea9ccabf34de2 /runtime/src
parenta28927849adb4e40dfdec8c32fb6758dcd205a37 (diff)
retire_tickets: coalesce pending_through per semaphore and guard completed_ monotonicity
Diffstat (limited to 'runtime/src')
-rw-r--r--runtime/src/retire_tickets.h16
1 files changed, 13 insertions, 3 deletions
diff --git a/runtime/src/retire_tickets.h b/runtime/src/retire_tickets.h
index a48302859..675460cac 100644
--- a/runtime/src/retire_tickets.h
+++ b/runtime/src/retire_tickets.h
@@ -24,7 +24,7 @@ public:
24 while (!pending_.empty()) { 24 while (!pending_.empty()) {
25 const Entry& front = pending_.front(); 25 const Entry& front = pending_.front();
26 if (!front.idle && !query(front.semaphore, front.value)) break; 26 if (!front.idle && !query(front.semaphore, front.value)) break;
27 completed_ = front.ticket; 27 if (front.ticket > completed_) completed_ = front.ticket;
28 pending_.pop_front(); 28 pending_.pop_front();
29 } 29 }
30 return completed_; 30 return completed_;
@@ -34,8 +34,18 @@ public:
34 // that must have them done (and may not hold the lock that guards this object while it waits) waits for. 34 // that must have them done (and may not hold the lock that guards this object while it waits) waits for.
35 std::vector<std::pair<Semaphore, std::uint64_t>> pending_through(std::uint64_t ticket) const { 35 std::vector<std::pair<Semaphore, std::uint64_t>> pending_through(std::uint64_t ticket) const {
36 std::vector<std::pair<Semaphore, std::uint64_t>> out; 36 std::vector<std::pair<Semaphore, std::uint64_t>> out;
37 for (const Entry& entry : pending_) 37 for (const Entry& entry : pending_) {
38 if (entry.ticket <= ticket && !entry.idle) out.emplace_back(entry.semaphore, entry.value); 38 if (entry.ticket > ticket || entry.idle) continue;
39 bool merged = false;
40 for (auto& [sem, val] : out) {
41 if (sem == entry.semaphore) {
42 if (entry.value > val) val = entry.value;
43 merged = true;
44 break;
45 }
46 }
47 if (!merged) out.emplace_back(entry.semaphore, entry.value);
48 }
39 return out; 49 return out;
40 } 50 }
41 51