Realtime safe, waitfree, concurrency library

Add new test case

authored by inkreas.ing and committed by inkreas.ing 3bc87aea 7acad74c

Changed files
+29 -1
tests
+29 -1
tests/tests.rs
··· 1 1 #[cfg(test)] 2 2 mod usage_test { 3 - use simple_left_right::{Absorb, WriteGuard, Writer}; 3 + use simple_left_right::{Absorb, ReadGuard, WriteGuard, Writer}; 4 4 use std::{cell::Cell, hint, time::Duration}; 5 5 6 6 fn spin_lock<T: Absorb<O>, O>(writer: &mut Writer<T, O>) -> WriteGuard<'_, T, O> { ··· 273 273 assert!(value <= *lock.read()); 274 274 lock.apply_op(CounterAddOp(1)); 275 275 drop(lock); 276 + } 277 + } 278 + 279 + #[test] 280 + // attempt to find similar breakge to: https://github.com/rust-lang/rust/issues/63787 281 + // i don't think it's possible, because you can't get a ref to the other value while still passing 282 + // a ref through the function boundary. You can only get a ref to the other value when passing Reader, 283 + // which already has a raw ptr. So i think i am not affected by this issue. 284 + fn break_ref() { 285 + #[derive(Clone, Copy)] 286 + struct SetToNone; 287 + impl Absorb<SetToNone> for Option<Box<i32>> { 288 + fn absorb(&mut self, _operation: SetToNone) { 289 + *self = None; 290 + } 291 + } 292 + 293 + let mut writer = Writer::new(Some(Box::new(0))); 294 + let mut reader = writer.build_reader().unwrap(); 295 + 296 + two_refs(&mut writer.try_lock().unwrap(), reader.lock()); 297 + 298 + fn two_refs( 299 + writer: &mut WriteGuard<'_, Option<Box<i32>>, SetToNone>, 300 + reader: ReadGuard<'_, Option<Box<i32>>>, 301 + ) { 302 + drop(reader); 303 + writer.apply_op(SetToNone); 276 304 } 277 305 } 278 306 }