{"id":32806412,"url":"https://github.com/sh1zen/crossync","last_synced_at":"2025-11-06T14:01:44.204Z","repository":{"id":320452275,"uuid":"1081805209","full_name":"sh1zen/crossync","owner":"sh1zen","description":"Blazingly fast concurrent Data Structures for Rust.","archived":false,"fork":false,"pushed_at":"2025-11-03T20:31:41.000Z","size":67,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-03T22:17:57.336Z","etag":null,"topics":["concurrent-programming","data-structures","dev-tools","rust-lang","rust-library"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/crossync","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sh1zen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-23T10:08:02.000Z","updated_at":"2025-11-03T20:31:44.000Z","dependencies_parsed_at":"2025-10-23T22:25:08.257Z","dependency_job_id":"8d95a77b-179e-4ce2-ad3d-9152727a37b6","html_url":"https://github.com/sh1zen/crossync","commit_stats":null,"previous_names":["sh1zen/crossync"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/sh1zen/crossync","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sh1zen%2Fcrossync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sh1zen%2Fcrossync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sh1zen%2Fcrossync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sh1zen%2Fcrossync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sh1zen","download_url":"https://codeload.github.com/sh1zen/crossync/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sh1zen%2Fcrossync/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":283019357,"owners_count":26765637,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-06T02:00:06.180Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["concurrent-programming","data-structures","dev-tools","rust-lang","rust-library"],"created_at":"2025-11-06T14:00:59.013Z","updated_at":"2025-11-06T14:01:44.199Z","avatar_url":"https://github.com/sh1zen.png","language":"Rust","readme":"# 📦 Blazingly Fast Concurrent Data Structures\n\n- 🪪 Thread-safe with spin-lock backoff and kernel-level mutexes\n- ⚡ Optimized for high-concurrency workloads\n- 💾 Optimized cloning with safe memory management via internal reference counting \n- 🔐 Internal mutability\n\n---\n\n## ✨ AtomicVec\n\n**AtomicVec\u003cT\u003e** is a high-performance, thread-safe vector supporting concurrent push and pop operations with minimal locking overhead.\nIt uses block-based allocation, atomic indices, and internal backoff strategies to manage memory efficiently in multi-threaded contexts.\n\n- 🧠 Suitable for implementing queues, stacks, and other dynamic collections\n- 🛡️ Shared/exclusive locking for safe access and reset operations\n- ♻️ Automatic block recycling and free-list management\n- 📦 Can convert to standard Vec\u003cT\u003e safely, consuming elements\n\n### Example\n\n```rust\nuse std::thread;\nuse crossync::atomic::AtomicVec;\n    \nlet h = AtomicVec::new();\n\nh.push(\"hello\");\nlet b = h.clone();\ndrop(h);\n\n{\n    let b = b.clone();\n    let t = thread::spawn(move || {\n        if let Some(v) = b.pop() {\n            assert_eq!(v, \"hello\");\n        }\n    });\n    t.join().unwrap();\n}\n\nassert!(b.pop().is_none());\n```\n\n---\n\n## ✨ AtomicHashMap\n\n**AtomicHashMap** a blazingly fast thread-safe, concurrent hash map that supports high-performance insertion, retrieval, and removal of key-value pairs.  \nIt uses fine-grained atomic operations combined with internal mutexes to manage contention efficiently.\n\n- 🧠 Ideal for shared caches, state maps, and in high concurrency scenario\n- 📏 It uses resizable bucket array to optimize hash distribution and performance\n\n### Example\n\n```rust\nuse std::thread;\nuse crossync::atomic::AtomicHashMap;\n    \nlet h = AtomicHashMap::new();\n\nh.insert(\"c\", \"hello\");\nlet b = h.clone();\ndrop(h);\n\n{\n    let b = b.clone();\n    let t = thread::spawn(move || {\n        if let Some(mut v) = b.get_mut(\"c\") {\n            *v = \"world\"\n        }\n    });\n    t.join().unwrap();\n}\n\nassert_eq!(b.get(\"c\").unwrap(), \"world\");\n```\n\n---\n\n## ✨ AtomicBuffer\n\n**AtomicBuffer** is a lock-free, bounded, and thread-safe ring buffer.  \nIt provides atomic push and pop operations without requiring locks, making it ideal for high-performance concurrent producer/consumer systems.\n\n- 🧠 Suitable for work queues, message passing, or object pooling systems\n\n### Example\n\n```rust\nuse crossync::atomic::AtomicBuffer;\nuse std::thread;\n\nlet buffer = AtomicBuffer::with_capacity(2);\n\nlet producer = {\n    let buffer = buffer.clone();\n    thread::spawn(move || {\n        let _ = buffer.push(Box::into_raw(Box::new(1)));\n        let _ = buffer.push(Box::into_raw(Box::new(2)));\n    })\n};\n\nlet consumer = {\n    let buffer = buffer.clone();\n    thread::spawn(move || {\n        let mut count = 1;\n        while count \u003c= 2 {\n            if let Some(ptr) = buffer.pop() {\n                let val = unsafe { *Box::from_raw(ptr) };\n                assert_eq!(val, count);\n                count += 1;\n            }\n        }\n    })\n};\n\nproducer.join().unwrap();\nconsumer.join().unwrap();\n```\n\n---\n\n## ✨ AtomicCell\n\n**AtomicCell** is a thread-safe, lock-assisted atomic container that provides interior mutability with cloneable reference counting.  \nIt combines mutex-protected access, raw memory management, and atomic reference counting to safely store and manipulate a single value in concurrent environments.\n\n- 🧠 Ideal for shared single-value state in multithreaded programs\n\n### Example\n\n```rust\nuse std::thread;\nuse crossync::atomic::AtomicCell;\n\nlet c = AtomicCell::new(10);\nlet c2 = c.clone();\n\nlet handle = thread::spawn(move || {\n    let mut v = c2.get_mut();\n    *v += 1;\n});\n\nhandle.join().unwrap();\n\nassert_eq!(*c.get(), 11);\n```\n\n---\n\n## ✨ AtomicArray\n\n**AtomicArray** is a lock-assisted, thread-safe array optimized for concurrent reads and writes.  \nIt combines atomic indices, per-slot locks, and cache-friendly memory layout to provide efficient and safe access in multi-threaded environments.\n\n- 🧠 Optimized for high-concurrency workloads with backoff spins\n\n### Example\n\n```rust\nuse std::thread;\nuse crossync::atomic::AtomicArray;\n\nlet arr = AtomicArray::with_capacity(4);\nlet arr_clone = arr.clone();\n\nlet t = thread::spawn(move || {\n    let _ = arr_clone.push(10);\n});\n\nt.join().unwrap();\n\narr.for_each_mut(|v| {\n    *v *= 2;\n});\n\nassert_eq!(*arr.get(0).unwrap(), 20);\n```\n\n---\n\n## ✨ Atomic\u003cT\u003e — Universal Atomic Wrapper\n\n**Atomic\u003cT\u003e** is a powerful generic atomic type providing thread-safe access to **any** Rust type `T`.  \nIt supports complex types, structs, enums, collections, primitives, and user-defined data — all synchronized via an internal `SMutex`.\n\n- 🧠 Works with **any type**: primitives, structs, enums, strings, vectors, and custom types\n- 🔄 Provides **atomic load, store, swap, update, and compare-exchange** operations\n- 🧩 Specialized methods for common containers (`Vec\u003cT\u003e`, `String`, `Option\u003cT\u003e`)\n- 🧮 Supports numeric and bitwise atomic operations (`fetch_add`, `fetch_sub`, etc.)\n- 🔐 Thread-safe interior mutability with minimal overhead\n\n### Example\n\n```rust\nuse crossync::atomic::Atomic;\nuse std::sync::Arc;\nuse std::thread;\n\n#[derive(Debug, Clone, PartialEq)]\nstruct Person {\n    name: String,\n    age: u32,\n}\n\nlet atomic = Arc::new(Atomic::new(Person {\n    name: \"Alice\".to_string(),\n    age: 30,\n}));\n\nlet atomic2 = atomic.clone();\nlet handle = thread::spawn(move || {\n    atomic2.update(|p| {\n        p.name = \"Bob\".to_string();\n        p.age += 1;\n    });\n});\n\nhandle.join().unwrap();\n\nlet result = atomic.load();\nassert_eq!(result.name, \"Bob\");\nassert_eq!(result.age, 31);\n```\n\n---\n\n## ✨ RwLock\n\n**RwLock** is a lightweight, synchronization primitive for safe concurrent access. It provides multi-reader / single-writer locking with minimal kernel interaction.\n\n - ⚡ Fast atomic + futex-based design\n - 🔒 Shared (read) and exclusive (write) modes\n - 🧩 Clonable via internal ref-count (no data copy)\n - ✅ Compared to std::RwLock: user-space (faster, no poisoning, clonable).\n\n### Example\n\n```rust\nuse crossync::sync::RwLock;\nuse std::thread;\nuse std::thread::sleep;\nuse std::time::Duration;\n\nlet mutex = RwLock::new(5);\n\nlet m1 = mutex.clone();\n\nlet h1 = thread::spawn(move || {\nlet _guard = m1.lock_exclusive();\nsleep(Duration::from_millis(10));\n});\n\nlet m2 = mutex.clone();\nlet h2 = thread::spawn(move || {\nlet _guard = m2.lock_shared();\nsleep(Duration::from_millis(10));\n});\n\nh1.join().unwrap();\nh2.join().unwrap();\n```\n\n---\n\n## ✨ Barrier — Thread Synchronization Primitive\n\n**Barrier** is a lightweight, thread-safe synchronization primitive that coordinates groups of threads.  \nIt blocks threads until a specified number of waiters arrive, then releases them all simultaneously.  \nOnce released, the barrier resets to a configurable capacity for reuse.\n\n- 🧠 Suitable for parallel algorithms, phased execution, and workload synchronization\n\n### Example\n\n```rust\nuse crossync::sync::Barrier;\nuse std::thread;\n\nlet barrier = Barrier::with_capacity(3, 0);\n\nlet mut handles = vec![];\nfor _ in 0..3 {\n    let c = barrier.clone();\n    handles.push(thread::spawn(move || {\n        println!(\"Waiting...\");\n        c.wait();\n        println!(\"Released!\");\n    }));\n}\n\nfor h in handles {\n    h.join().unwrap();\n}\n```\n\n---\n\n## 📦 Installation\n\nInstall `crossync` from crates.io  \nOpen your `Cargo.toml` and add:\n\n```toml\n[dependencies]\ncrossync = \"0.0.4\" # or the latest version available\n```\n\n---\n\n## 📄 License\n\nApache-2.0\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsh1zen%2Fcrossync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsh1zen%2Fcrossync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsh1zen%2Fcrossync/lists"}