Skip to content

Instantly share code, notes, and snippets.

View playX18's full-sized avatar

playX18

View GitHub Profile
(define-library (rope)
(import (core records)
(core optargs))
(export
*short-leaf*
*long-leaf*
rope?
branch?
leaf?
make-rope
@playX18
playX18 / thread.rs
Last active December 30, 2024 01:52
use std::{
cell::{RefCell, UnsafeCell},
marker::PhantomData,
mem::{ManuallyDrop, MaybeUninit},
sync::{
Arc,
atomic::{
AtomicBool, AtomicI8, AtomicI32, AtomicU8, AtomicU32, AtomicU64, AtomicUsize, Ordering,
},
},
use super::semaphore::Sem;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::{self, Ordering};
/// Synchronization primitive inspired by RCU.
///
/// Any number of threads may enter critical sections associated with a
/// synchronizer object. One (at a time) other thread may wait for the
/// completion of all critical sections for the synchronizer object
/// that were extant when the wait was initiated. Usage is that there
@playX18
playX18 / value.rs
Created September 12, 2024 04:05
Simple tagged pointers & Slots
#[allow(dead_code)]
impl ValueSlot {
const TAG_UNTAGGED: usize = 0x0;
const TAG_TAGGED: usize = 0x1;
/* some extra tags are available in case we need them in future */
const TAG_UNUSED0: usize = 0x2;
const TAG_UNUSED1: usize = 0x3;
const TAG_UNUSED2: usize = 0x4;
const TAG_UNUSED3: usize = 0x5;
const TAG_UNUSED4: usize = 0x6;