about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tvix/eval/src/value/thunk.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/tvix/eval/src/value/thunk.rs b/tvix/eval/src/value/thunk.rs
index 1be3370b23..1c7ed61552 100644
--- a/tvix/eval/src/value/thunk.rs
+++ b/tvix/eval/src/value/thunk.rs
@@ -488,3 +488,14 @@ impl ThunkSet {
         self.0.insert(ptr)
     }
 }
+
+#[derive(Default, Clone)]
+pub struct SharedThunkSet(Rc<RefCell<ThunkSet>>);
+
+impl SharedThunkSet {
+    /// Check whether the given thunk has already been seen. Will mark the thunk
+    /// as seen otherwise.
+    pub fn insert(&self, thunk: &Thunk) -> bool {
+        self.0.borrow_mut().insert(thunk)
+    }
+}