From 6c135e301290b6809288bf40eabd7b1d86373f8e Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 17 Aug 2023 16:27:57 +0100 Subject: [PATCH] W --- Cargo.toml | 1 + src/main.rs | 36 ++++++++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 00c5180..c68f178 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ edition = "2021" downcast-rs = "1" dumpster = "0.1.1" futures = "0.3.28" +#parking_lot = "0.12.1" #tokio = { version = "1", features = ["full"] } #serde-value = "0.7" #serde = { version="1", features=["derive"] } diff --git a/src/main.rs b/src/main.rs index 9ce70ab..73a1024 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,36 @@ -use futures::channel::oneshot; -enum Void {} +use std::cell::RefCell; + +use dumpster::{Collectable, unsync::Gc}; + +#[derive(Collectable, Debug)] +struct Loopy { + value: u32, + loopy: RefCell>>, +} + +impl Drop for Loopy { + fn drop(&mut self) { + eprintln!( + "drop {:?} {:?}", + self.value, + self.loopy.borrow().as_ref().map(|gcl| gcl.value), + ); + } +} fn main() { - type F = futures::future::Shared>; - println!("{:?}", std::alloc::Layout::new::()); + let a = Gc::new(Loopy { + value: 42, + loopy: None.into(), + }); + let b = Gc::new(Loopy { + value: 66, + loopy: None.into(), + }); + *a.loopy.borrow_mut() = Some(b.clone()); + *b.loopy.borrow_mut() = Some(a.clone()); + drop(a); + drop(b); + } -- 2.30.2