84 releases
| 0.8.29 | Apr 2, 2026 |
|---|---|
| 0.8.28 | Mar 11, 2026 |
| 0.8.27 | Feb 23, 2026 |
| 0.8.25 | Dec 27, 2025 |
| 0.1.2 | Nov 10, 2016 |
#627 in Rust patterns
3,257 downloads per month
Used in 3 crates
225KB
4K
SLoC
gstuff - Small macro and trinkets that make my life easier.
lib.rs:
Iterates over 0..len or a slice in pseudo-random order, with zero allocation.
Uses a Feistel-like bijective permutation combined with cycle-walking to visit every index exactly once.
ShuffledIter Methods
fn with_seed (len: usize, seed: u64) -> ShuffledIterCreates new iterator over0..lenusing given seed.
Functions
fn shuffled<T> (seed: u64, v: &[T]) -> impl Iterator<Item = (usize, &T)>Iterates over slice in random order, yielding(index, &T).
TPool Methods
fn post (&self, task: Box<dyn Task>) -> Re<()>Runs given task from one ofsponsored threads.fn post_at (&self, next_ms: u64, task: Box<dyn Task>) -> Re<()>Schedules task to run atnext_msepoch from one ofsponsored threads.fn fin (&self, tag: InlinableString, fin: Box<dyn TTask>) -> boolRegisters given task, if not already per tag, to be run (FIFO) onbye. FnOnce tasks complete immediately; TTask implementations returning Repeat run instop.fn jobsⁿ (&self) -> Re<usize>Number of jobs queued or running.fn threadsⁿ (&self) -> usizeNumber of threads in the pool.fn bye (&self) -> usizeSignals threads to exit, runs finalizers, prevents new jobs from being posted.fn stop (&self) -> usizeNon-blocking stop: joins finished threads, runs fin timers.
Global Functions
fn tpool() -> Result<AReadGuard<'static, TPool, TPool>, AArcErr>Shared thread pool.fn tpost (spin: u32, threads: u8, task: Box<dyn Task>) -> Re<bool>Poststaskto sharedTPOOLifthreadsare in it, or runs on current thread otherwise.
Dependencies
~0–12MB
~250K SLoC