upleb.uk

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

summaryrefslogtreecommitdiff
path: root/runtime/src/deferred_image_binding.h
diff options
context:
space:
mode:
authord7ommy <abnalstlll@gmail.com>2026-11-25 22:09:19 +0300
committerd7ommy <abnalstlll@gmail.com>2026-11-25 22:09:19 +0300
commit14e1a352c445aef86d4cd0eca0444565a07f67ca (patch)
treedd2a67888f74730862b994d2377bee32aff20913 /runtime/src/deferred_image_binding.h
parent490f5b9ec2433104da9af73c5b361035a45896f3 (diff)
runtime: guard null bind callbacks, add owner accessor and unit test suite for DeferredImageBinding (RT-DEFERRED-IMAGE-BINDING-GUARDS-AND-TESTS)
Claimed in Issue #1608 as RT-DEFERRED-IMAGE-BINDING-GUARDS-AND-TESTS. AI-assisted (Claude Code)
Diffstat (limited to 'runtime/src/deferred_image_binding.h')
-rw-r--r--runtime/src/deferred_image_binding.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/runtime/src/deferred_image_binding.h b/runtime/src/deferred_image_binding.h
index 668cf593d..6ef544199 100644
--- a/runtime/src/deferred_image_binding.h
+++ b/runtime/src/deferred_image_binding.h
@@ -11,12 +11,13 @@ class DeferredImageBinding {
11public: 11public:
12 using Bind = bool (*)(void*); 12 using Bind = bool (*)(void*);
13 DeferredImageBinding(void* owner, Bind bind) : owner_(owner), bind_(bind) {} 13 DeferredImageBinding(void* owner, Bind bind) : owner_(owner), bind_(bind) {}
14 void* owner() const { return owner_; }
14 bool bound() const { return bound_.load(std::memory_order_acquire); } 15 bool bound() const { return bound_.load(std::memory_order_acquire); }
15 bool ensure() { 16 bool ensure() {
16 if (bound()) return true; 17 if (bound()) return true;
17 std::lock_guard lock(mutex_); 18 std::lock_guard lock(mutex_);
18 if (bound()) return true; 19 if (bound()) return true;
19 if (!bind_(owner_)) return false; 20 if (!bind_ || !bind_(owner_)) return false;
20 bound_.store(true, std::memory_order_release); 21 bound_.store(true, std::memory_order_release);
21 return true; 22 return true;
22 } 23 }