about summary refs log tree commit diff
path: root/tvix/eval
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2023-02-26T15·28+0300
committertazjin <tazjin@tvl.su>2023-03-04T15·18+0000
commite1f082a3ab012b0ef3b52b2b5b05513df75a4930 (patch)
tree00cd2ec886d20dfc3ad473578cf47c40a64a4fea /tvix/eval
parentdccbda596067a7650eeeec96433b715909ba43b8 (diff)
feat(tvix/eval): add SharedThunkSet r/5886
This is a ThunkSet wrapped to be shareable, which will be required
once ThunkSets are embedded in futures.

Change-Id: I5a067b7972ac86e4d354c75ef05c86b2284c1137
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8144
Tested-by: BuildkiteCI
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Diffstat (limited to 'tvix/eval')
-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 1be3370b2377..1c7ed615527c 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)
+    }
+}