]> Repositorios git - scryer-prolog.git/commitdiff
Enable multiple Machines per process by having ATOM_TABLE_BUF_BASE always be thread_l...
authorNicolas Luck <[email protected]>
Wed, 23 Aug 2023 12:36:07 +0000 (14:36 +0200)
committerNicolas Luck <[email protected]>
Wed, 23 Aug 2023 12:36:07 +0000 (14:36 +0200)
src/atom_table.rs

index 48f50ec948a162b7fe2c4cfa70823c228490958b..11693484d2a9a0a43aee1a8527d151868024d4b8 100644 (file)
@@ -40,17 +40,11 @@ impl From<bool> for Atom {
 const ATOM_TABLE_INIT_SIZE: usize = 1 << 16;
 const ATOM_TABLE_ALIGN: usize = 8;
 
-#[cfg(test)]
 thread_local! {
    static ATOM_TABLE_BUF_BASE: std::cell::RefCell<*const u8> = std::cell::RefCell::new(ptr::null_mut());
 }
 
-#[cfg(not(test))]
-static ATOM_TABLE_BUF_BASE: std::sync::atomic::AtomicPtr<u8> =
-    std::sync::atomic::AtomicPtr::new(ptr::null_mut());
-
 fn set_atom_tbl_buf_base(old_ptr: *const u8, new_ptr: *const u8) -> Result<(), *const u8> {
-#[cfg(test)]
     {
     ATOM_TABLE_BUF_BASE.with(|atom_table_buf_base| {
         let mut borrow = atom_table_buf_base.borrow_mut();
@@ -62,30 +56,12 @@ fn set_atom_tbl_buf_base(old_ptr: *const u8, new_ptr: *const u8) -> Result<(), *
             }
         })?;
     };
-    #[cfg(not(test))]
-    {
-        ATOM_TABLE_BUF_BASE
-            .compare_exchange(
-                old_ptr.cast_mut(),
-                new_ptr.cast_mut(),
-                std::sync::atomic::Ordering::Relaxed,
-                std::sync::atomic::Ordering::Relaxed,
-            )
-            .map_err(|ptr| ptr.cast_const())
-    }?;
     Ok(())
 }
 
 pub(crate) fn get_atom_tbl_buf_base() -> *const u8 {
-    #[cfg(test)]
-    {
     ATOM_TABLE_BUF_BASE.with(|atom_table_buf_base| *atom_table_buf_base.borrow())
 }
-#[cfg(not(test))]
-    {
-        ATOM_TABLE_BUF_BASE.load(std::sync::atomic::Ordering::Relaxed)
-    }
-}
 
 #[test]
 #[should_panic(expected = "Overwriting atom table base pointer")]