Datasets:
text stringlengths 100 48.3k | sample_type stringclasses 3
values | source_repo stringclasses 103
values | source_file stringlengths 6 116 | license stringclasses 9
values | content_sha256 stringlengths 64 64 | char_count int64 100 48.3k | line_count int64 1 498 | source_count int64 1 41 | source_records_json stringlengths 70 5.88k | sample_types_json stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|---|---|
use std::{env, process};
#[derive(Copy, Clone)]
pub struct ArgRange {
current: usize,
limit: usize,
step: usize,
}
impl ArgRange {
pub fn is_single(&self) -> bool {
self.current.saturating_add(self.step) > self.limit
}
}
impl Iterator for ArgRange {
type Item = usize;
fn next(&mut... | code | Amanieu/parking_lot | benchmark/src/args.rs | MIT OR Apache-2.0 | ee1415b50e8cc12cf300b0a93733fe3fe9b5bcb0c7503b963c54044e05d089c6 | 3,030 | 108 | 1 | [{"repository": "Amanieu/parking_lot", "file": "benchmark/src/args.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
use parking_lot_benchmark::args;
use parking_lot_benchmark::args::ArgRange;
#[cfg(any(windows, unix))]
use std::cell::UnsafeCell;
use std::{
sync::{
Arc, Barrier,
atomic::{AtomicBool, Ordering},
},
thread,
time::Duration,
};
trait Mutex<T> {
fn new(v: T) -> Self;
fn lock<F, R>(... | code | Amanieu/parking_lot | benchmark/src/bin/mutex.rs | MIT OR Apache-2.0 | 589e5cabd12674a938ce49dc3799cfeea6a4e6f0a6838d22d5f2e2662768021f | 4,113 | 160 | 1 | [{"repository": "Amanieu/parking_lot", "file": "benchmark/src/bin/mutex.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
let barrier = Arc::new(Barrier::new(num_threads));
let mut threads = vec![];
for _ in 0..num_threads {
let barrier = barrier.clone();
let lock = lock.clone();
let keep_going = keep_going.clone();
threads.push(thread::spawn(move || {
let mut local_value = 0.0;
... | code | Amanieu/parking_lot | benchmark/src/bin/mutex.rs | MIT OR Apache-2.0 | 99cb0a81def7b9785b170e782d139a63b8f8101402dac646e2fc4d1b8f7e3fd1 | 4,938 | 160 | 1 | [{"repository": "Amanieu/parking_lot", "file": "benchmark/src/bin/mutex.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
"secondsPerTest",
"testIterations",
]);
let mut first = true;
for num_threads in args[0] {
for work_per_critical_section in args[1] {
for work_between_critical_sections in args[2] {
for seconds_per_test in args[3] {
for test_iterations in args[... | code | Amanieu/parking_lot | benchmark/src/bin/mutex.rs | MIT OR Apache-2.0 | 842ff36fffd4a9b13c20cbd18165d76f9716bce24af4a3cee876bd26e3300f82 | 778 | 24 | 1 | [{"repository": "Amanieu/parking_lot", "file": "benchmark/src/bin/mutex.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
use parking_lot_benchmark::args;
use parking_lot_benchmark::args::ArgRange;
#[cfg(any(windows, unix))]
use std::cell::UnsafeCell;
use std::{
sync::{
Arc, Barrier,
atomic::{AtomicBool, Ordering},
},
thread,
time::Duration,
};
trait RwLock<T> {
fn new(v: T) -> Self;
fn read<F, R>... | code | Amanieu/parking_lot | benchmark/src/bin/rwlock.rs | MIT OR Apache-2.0 | b128360c346ac1a700dddba5759985d467a1fd3cb4b382dfcdef9ea648e5b089 | 3,580 | 160 | 1 | [{"repository": "Amanieu/parking_lot", "file": "benchmark/src/bin/rwlock.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
#[cfg(not(unix))]
type PthreadRwLock<T> = std::sync::RwLock<T>;
#[cfg(unix)]
struct PthreadRwLock<T>(UnsafeCell<T>, UnsafeCell<libc::pthread_rwlock_t>);
#[cfg(unix)]
unsafe impl<T> Sync for PthreadRwLock<T> {}
#[cfg(unix)]
impl<T> RwLock<T> for PthreadRwLock<T> {
fn new(v: T) -> Self {
PthreadRwLock(
... | code | Amanieu/parking_lot | benchmark/src/bin/rwlock.rs | MIT OR Apache-2.0 | 163441aabf8fad30bdf5b26d3cabb7eaa3c18be850556f9da26d16b845eebf51 | 5,107 | 159 | 1 | [{"repository": "Amanieu/parking_lot", "file": "benchmark/src/bin/rwlock.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
) {
let mut writers = vec![];
let mut readers = vec![];
for _ in 0..test_iterations {
let (run_writers, run_readers) = run_benchmark::<M>(
num_writer_threads,
num_reader_threads,
work_per_critical_section,
work_between_critical_sections,
s... | code | Amanieu/parking_lot | benchmark/src/bin/rwlock.rs | MIT OR Apache-2.0 | 5662f834fa244da95150940a1838e9d78bf88b49baab1673e97681bbdebe85f8 | 4,240 | 132 | 1 | [{"repository": "Amanieu/parking_lot", "file": "benchmark/src/bin/rwlock.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
//! This library exposes a low-level API for creating your own efficient
//! synchronization primitives.
//!
//! # The parking lot
//!
//! To keep synchronization primitives small, all thread queuing and suspending
//! functionality is offloaded to the *parking lot*. The idea behind this is based
//! on the WebKit [`WT... | code | Amanieu/parking_lot | core/src/lib.rs | MIT OR Apache-2.0 | 7de259f5b0aa39ccfc91c5d184f72573bbfd246b9d817ed369d79cb59570689f | 2,790 | 70 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/lib.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
use crate::thread_parker::{ThreadParker, ThreadParkerT, UnparkHandleT};
use crate::word_lock::WordLock;
use core::{
cell::{Cell, UnsafeCell},
mem,
ptr::{self, NonNull},
sync::atomic::{AtomicPtr, AtomicUsize, Ordering},
};
use smallvec::SmallVec;
use std::time::Instant;
static NUM_THREADS: AtomicUsize =... | code | Amanieu/parking_lot | core/src/parking_lot.rs | MIT OR Apache-2.0 | 8a96cd8c4bc0cb0df7ae74c16c6ed7317dc2b665890a6720181072844707f0a9 | 5,540 | 160 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/parking_lot.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
next_in_queue: Option<NonNull<ThreadData>>,
// Written by the parking lot before `unpark_lock` and read locally only
// after a successful return from the parker.
unpark_token: UnparkToken,
// Initialized before linking and subsequently read only under the bucket
// lock.
park_token: ParkToken... | code | Amanieu/parking_lot | core/src/parking_lot.rs | MIT OR Apache-2.0 | ce630ebfac9575ba0c06580d2fe512d8e8787a2eda983e9d4b0a55df2d659537 | 6,060 | 160 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/parking_lot.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
// Unlock buckets and try again
for bucket in &table.entries[..] {
// SAFETY: We hold the lock here, as required
unsafe { bucket.mutex.unlock() };
}
};
// Create the new table
let mut new_table = HashTable::new(num_threads, Some(NonNull::from(old_table)));
// Mo... | code | Amanieu/parking_lot | core/src/parking_lot.rs | MIT OR Apache-2.0 | fafa38a50e6f7d3ddb9c9d752b22df60248e13f2b55b5a150182ab6b0a3152a6 | 6,204 | 160 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/parking_lot.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
};
// Lock the first bucket
bucket1.mutex.lock();
// If no other thread has rehashed the table before we grabbed the lock
// then we are good to go! The lock we grabbed prevents any rehashes.
if ptr::eq(HASHTABLE.load(Ordering::Relaxed), hashtable) {
// Now lock the... | code | Amanieu/parking_lot | core/src/parking_lot.rs | MIT OR Apache-2.0 | 12f145f826bd1e4fe383b43d75cf6fe2bcd38cf7c79afc8fe9498aee3b60c1bd | 5,371 | 160 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/parking_lot.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
/// whether it was the last thread in the queue.
///
/// A timeout is the earliest point at which this function may return
/// [`ParkResult::TimedOut`]. Scheduling and platform-specific behavior may
/// delay the actual return.
///
/// # Safety
///
/// You should only call this function with an address that you control... | code | Amanieu/parking_lot | core/src/parking_lot.rs | MIT OR Apache-2.0 | 5accabfd4475eb988d0ecd2704096b3c144a97ee8fd0c59df1e87fca2592edbe | 6,663 | 160 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/parking_lot.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
// There should be no way for our thread to have been removed from the queue
// if we timed out.
debug_assert!(current.is_some());
// Unlock the bucket, we are done
// SAFETY: We hold the lock here, as required
unsafe { bucket.mutex.unlock() };
ParkResult::TimedOut
}... | code | Amanieu/parking_lot | core/src/parking_lot.rs | MIT OR Apache-2.0 | 9ede83268058eb152a6b9d424eb2ac24573a229ae00e09103a635e2d212e1efa | 6,178 | 160 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/parking_lot.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
if let Some(previous) = previous {
unsafe { previous.as_ref().state() }.next_in_queue = next;
} else {
bucket.queue_head.set(next);
}
if bucket.queue_tail.get() == Some(current_ptr) {
bucket.queue_tail.set(previous);
}
... | code | Amanieu/parking_lot | core/src/parking_lot.rs | MIT OR Apache-2.0 | e6b057df159c08f638c03b9840f2a44779cf7e69289544502525b3e3a8760115 | 6,583 | 159 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/parking_lot.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
}
current = next;
} else {
previous = Some(current_ptr);
current = next;
}
}
// Add the requeued threads to the destination bucket
if let Some(requeue_threads) = requeue_threads {
let requeue_threads_tail = requeue_threads_tail.unwrap();
u... | code | Amanieu/parking_lot | core/src/parking_lot.rs | MIT OR Apache-2.0 | a04a4c1306e410f2ac9837445ea62cdb34f76517dccbb9adce346f41862f5e76 | 6,059 | 159 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/parking_lot.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
// Now that we are outside the lock, wake up all the threads that we removed
// from the queue.
for (_, handle) in threads.into_iter() {
unsafe { handle.unwrap_unchecked().unpark() };
}
abort_on_panic.disarm();
result
}
/// \[Experimental\] Deadlock detection
///
/// Enabled via the `deadl... | code | Amanieu/parking_lot | core/src/parking_lot.rs | MIT OR Apache-2.0 | 8f3901b14c9d2357bb9b1a343727a06db79819c0eef5f14e52b2cc2e9c4cf742 | 5,117 | 160 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/parking_lot.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
// parking lot and taken locally only after the parker returns.
deadlock_backtrace: Option<mpsc::Sender<DeadlockedThread>>,
// Immutable after construction.
thread_id: ThreadId,
}
impl DeadlockData {
pub fn new() -> Self {
DeadlockData {
resources: V... | code | Amanieu/parking_lot | core/src/parking_lot.rs | MIT OR Apache-2.0 | 6875e59d4f71209165984501142ceb8b5b8a1ef3691b245b8150f4812a684381 | 6,353 | 160 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/parking_lot.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
for b in &table.entries[..] {
b.mutex.lock();
}
// Another thread may have replaced the hash table while its
// buckets were being locked. In that case, retry with the current
// table.
let new_table = get_hashtable();
if core::ptr... | code | Amanieu/parking_lot | core/src/parking_lot.rs | MIT OR Apache-2.0 | b9454454ce959b8ea5e95debad8ddd99099373d3b26e2aff1df8e09dfa0cdcda | 6,663 | 160 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/parking_lot.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn overlapping_cycles_form_one_component() {
let storage = [0u8; 3];
let thread1 = NonNull::from(&storage[0]).cast::<ThreadData>();
let thread2 = NonNull::from(&storage[1]).cast::<ThreadData>();
l... | code | Amanieu/parking_lot | core/src/parking_lot.rs | MIT OR Apache-2.0 | 45961be3f1781d5265ea54eb16e5ed22a4b20a64bf0c265c4a074a3e72f437b8 | 5,478 | 159 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/parking_lot.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
thread::sleep(delay);
for (test, _) in &tests {
test.unpark_one(unpark_index);
}
}
for (test, threads) in tests {
test.finish(num_single_unparks);
for thread in threads {
thread.join().expect("Test thread panic");
... | code | Amanieu/parking_lot | core/src/parking_lot.rs | MIT OR Apache-2.0 | b6286e3b7062a83064407d4d967338a2770d3dfe079d70ac9fc2c553e2d7d682 | 6,385 | 160 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/parking_lot.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
pub fn up(&self) {
let old_semaphore_value = self.semaphore.fetch_add(1, Ordering::SeqCst);
// Check if anyone was waiting on the semaphore. If they were, then pass ownership to them.
if old_semaphore_value < 0 {
// We need to continue until we have actually unparked... | code | Amanieu/parking_lot | core/src/parking_lot.rs | MIT OR Apache-2.0 | 845eff201155054e05b8ecf11b43fb33401cde130e3c681ad12d71def95497ff | 1,027 | 26 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/parking_lot.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
use crate::thread_parker;
use core::hint::spin_loop;
// Wastes some CPU time for the given number of iterations,
// using a hint to indicate to the CPU that we are spinning.
#[inline]
fn cpu_relax(iterations: u32) {
for _ in 0..iterations {
spin_loop()
}
}
/// A counter used to perform exponential bac... | code | Amanieu/parking_lot | core/src/spinwait.rs | MIT OR Apache-2.0 | a87e9b9591d3ea8021146b3d0f7351ffc2dfc486b3a46e27bd804d998097ad9b | 1,818 | 67 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/spinwait.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
//! A simple atomic-flag-based thread parker. Used on platforms without better
//! parking facilities available.
use core::sync::atomic::{AtomicBool, Ordering};
use std::thread;
use std::time::Instant;
// Helper type for putting a thread to sleep until some other thread wakes it up
pub struct ThreadParker {
parke... | code | Amanieu/parking_lot | core/src/thread_parker/generic.rs | MIT OR Apache-2.0 | 60d413b88ff1ac157aed8011d080681cf5dc88cb24ecb2326edbb13c3b1f5012 | 1,648 | 71 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/thread_parker/generic.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
use core::{
ptr::{self, NonNull},
sync::atomic::{AtomicBool, AtomicI32, Ordering},
};
use std::thread;
use std::time::{Duration, Instant};
fn errno() -> libc::c_int {
#[cfg(target_os = "linux")]
unsafe {
*libc::__errno_location()
}
#[cfg(target_os = "android")]
unsafe {
*lib... | code | Amanieu/parking_lot | core/src/thread_parker/linux.rs | MIT OR Apache-2.0 | 311f0067182abcfcbd408fb6a6a4a0090d2813207ee896408cb4c726b939447d | 4,807 | 160 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/thread_parker/linux.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
unsafe fn park(&self) {
while self.futex.load(Ordering::Acquire) != 0 {
self.futex_wait(None);
}
}
#[inline]
unsafe fn park_until(&self, timeout: Instant) -> bool {
while self.futex.load(Ordering::Acquire) != 0 {
let now = Instant::now();
if timeo... | code | Amanieu/parking_lot | core/src/thread_parker/linux.rs | MIT OR Apache-2.0 | 5f7f9f56a305dce3d374057d383fedd7f3c7cc2f99d2fd69fc45797f703c2ba1 | 3,109 | 99 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/thread_parker/linux.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
use std::time::Instant;
/// Trait for the platform thread parker implementation.
///
/// The unsafe methods form a protocol and implementations may rely on the
/// parker remaining at a stable address once it has been used. In particular,
/// the Unix implementation contains initialized pthread mutexes and condition
/... | code | Amanieu/parking_lot | core/src/thread_parker/mod.rs | MIT OR Apache-2.0 | 07a2c63cffcfe31b753737ddfa0397e425982aa936cf11b4ce57e56211b52441 | 4,446 | 117 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/thread_parker/mod.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
use core::{
ptr,
sync::atomic::{AtomicI32, Ordering},
};
use std::thread;
use std::time::Instant;
use syscall::{
call::futex,
data::TimeSpec,
error::{EAGAIN, EFAULT, EINTR, ETIMEDOUT, Error},
flag::{FUTEX_WAIT, FUTEX_WAKE},
};
const UNPARKED: i32 = 0;
const PARKED: i32 = 1;
// Helper type for ... | code | Amanieu/parking_lot | core/src/thread_parker/redox.rs | MIT OR Apache-2.0 | 9a02cece0b0de4e4fff4bdc4ca1eb6df0c1b7ed1cd54196ff4f045d287f19db6 | 3,620 | 136 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/thread_parker/redox.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
use core::sync::atomic::{AtomicBool, Ordering};
use std::io::ErrorKind;
use std::time::Instant;
use std::{
io,
os::fortanix_sgx::{
thread::current as current_tcs,
usercalls::{
self,
raw::{EV_UNPARK, Tcs, WAIT_INDEFINITE},
},
},
thread,
};
// Helper type f... | code | Amanieu/parking_lot | core/src/thread_parker/sgx.rs | MIT OR Apache-2.0 | 4361f7b68fccda243b38e7a5a378ae641e8f1d7040eea8d4c2317e6985b1d215 | 2,972 | 107 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/thread_parker/sgx.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
#[cfg(not(target_vendor = "apple"))]
use core::mem::MaybeUninit;
use core::{
cell::{Cell, UnsafeCell},
ptr::NonNull,
};
use libc;
use std::time::Instant;
use std::{thread, time::Duration};
// x32 Linux uses a non-standard type for tv_nsec in timespec.
// See https://sourceware.org/bugzilla/show_bug.cgi?id=1643... | code | Amanieu/parking_lot | core/src/thread_parker/unix.rs | MIT OR Apache-2.0 | 3c9819addd3b466f811adca29f3a68d33d067f27bb6d3d36092e619a397fceb8 | 5,807 | 160 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/thread_parker/unix.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
let r = unsafe { libc::pthread_condattr_init(attr.as_mut_ptr()) };
assert_eq!(r, 0);
let r =
unsafe { libc::pthread_condattr_setclock(attr.as_mut_ptr(), libc::CLOCK_MONOTONIC) };
assert_eq!(r, 0);
let r = unsafe { libc::pthread_cond_init(self.condvar.get(), attr.as_ptr()) };
... | code | Amanieu/parking_lot | core/src/thread_parker/unix.rs | MIT OR Apache-2.0 | 7e76409f17bce7fdee4e73ac965bfaa226601d718a7b8908153afa26b536877d | 3,893 | 109 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/thread_parker/unix.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
//! The wasm platform can't park when atomic support is not available.
//! So this ThreadParker just panics on any attempt to park.
use std::thread;
use std::time::Instant;
pub struct ThreadParker(());
impl super::ThreadParkerT for ThreadParker {
type UnparkHandle = UnparkHandle;
const IS_CHEAP_TO_CONSTRUCT... | code | Amanieu/parking_lot | core/src/thread_parker/wasm.rs | MIT OR Apache-2.0 | 56af45095fe1ac5c533aa7ed73e40eabce200cbb43ca5f7c8bdf5edaa9949c6e | 1,101 | 47 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/thread_parker/wasm.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
use core::{
arch::wasm32,
ptr::NonNull,
sync::atomic::{AtomicI32, Ordering},
};
use std::thread;
use std::time::Instant;
// Helper type for putting a thread to sleep until some other thread wakes it up
pub struct ThreadParker {
parked: AtomicI32,
}
const UNPARKED: i32 = 0;
const PARKED: i32 = 1;
impl... | code | Amanieu/parking_lot | core/src/thread_parker/wasm_atomic.rs | MIT OR Apache-2.0 | f6996ddcc76f9b43b009dad79a72180763c30ef70de3f37775550b414f33d315 | 2,631 | 97 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/thread_parker/wasm_atomic.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
#![allow(non_snake_case)]
//! Manual bindings to the small subset of the Win32 API used by this module.
//!
//! Keeping these stable system interfaces here avoids adding `windows-sys` or
//! `winapi` as a dependency of the foundational `parking_lot_core` crate.
pub const INFINITE: u32 = 4294967295;
pub const ERROR_TI... | code | Amanieu/parking_lot | core/src/thread_parker/windows/bindings.rs | MIT OR Apache-2.0 | 011b57387f7a7db2a57206dab193e24a961d92540dfdee0d8b379dea99d14c45 | 2,010 | 51 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/thread_parker/windows/bindings.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
use core::{
ffi,
mem::{self, MaybeUninit},
ptr::{self, NonNull},
};
use std::sync::atomic::{AtomicUsize, Ordering};
use std::time::Instant;
const STATE_UNPARKED: usize = 0;
const STATE_PARKED: usize = 1;
const STATE_TIMED_OUT: usize = 2;
use super::bindings::*;
#[allow(non_snake_case)]
pub struct KeyedEv... | code | Amanieu/parking_lot | core/src/thread_parker/windows/keyed_event.rs | MIT OR Apache-2.0 | 91225477f37ad45a1afa6fe8b5fc4e03772d6538fc84b163a75d0487f896f3eb | 5,657 | 160 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/thread_parker/windows/keyed_event.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
}
}
}
impl Drop for KeyedEvent {
#[inline]
fn drop(&mut self) {
unsafe {
let ok = CloseHandle(self.handle);
assert_ne!(ok, false.into());
}
}
}
// Handle for a thread that is about to be unparked. We need to mark the thread
// as unparked while holding the queue... | code | Amanieu/parking_lot | core/src/thread_parker/windows/keyed_event.rs | MIT OR Apache-2.0 | dc15d69187d2885aa15cf56324573a1010257df6d72a9eb709d9905faeb8444a | 1,020 | 35 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/thread_parker/windows/keyed_event.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
use core::sync::atomic::AtomicUsize;
use std::sync::LazyLock;
use std::time::Instant;
mod bindings;
mod keyed_event;
mod waitaddress;
enum Backend {
KeyedEvent(keyed_event::KeyedEvent),
WaitAddress(waitaddress::WaitAddress),
}
static BACKEND: LazyLock<Backend> = LazyLock::new(|| {
if let Some(waitaddress... | code | Amanieu/parking_lot | core/src/thread_parker/windows/mod.rs | MIT OR Apache-2.0 | 9d41c7637dae0eee809a37f8bf5adc25f5ce51c5357caab7afcb9682b8b923fd | 4,463 | 138 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/thread_parker/windows/mod.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
use core::{
mem,
ptr::NonNull,
sync::atomic::{AtomicUsize, Ordering},
};
use std::{ffi, time::Instant};
use super::bindings::*;
#[allow(non_snake_case)]
pub struct WaitAddress {
WaitOnAddress: WaitOnAddress,
WakeByAddressSingle: WakeByAddressSingle,
}
impl WaitAddress {
#[allow(non_snake_case... | code | Amanieu/parking_lot | core/src/thread_parker/windows/waitaddress.rs | MIT OR Apache-2.0 | e2e6f0719732140c081c8ced079864f264dda7e79c22c3eb5d01089ce30a431b | 3,503 | 114 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/thread_parker/windows/waitaddress.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
use crate::spinwait::SpinWait;
use crate::thread_parker::{ThreadParker, ThreadParkerT, UnparkHandleT};
use core::{
cell::Cell,
mem, ptr,
sync::atomic::{AtomicPtr, Ordering},
};
struct ThreadData {
parker: ThreadParker,
// Linked list of threads in the queue. The queue is split into two parts:
... | code | Amanieu/parking_lot | core/src/word_lock.rs | MIT OR Apache-2.0 | 0354204710e78c4e1b3806421ad44767c4c483d71648eb3c8c85e2da9591380d | 5,558 | 159 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/word_lock.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
// Add our thread to the front of the queue
let queue_head = state.queue_head();
if queue_head.is_null() {
thread_data.queue_tail.set(thread_data);
thread_data.prev.set(ptr::null());
} else {
thread_data.queue_ta... | code | Amanieu/parking_lot | core/src/word_lock.rs | MIT OR Apache-2.0 | c079f40ddaca340401484261a50ab63f55faabb46bbe4c6ec73df495805d53c7 | 5,888 | 159 | 1 | [{"repository": "Amanieu/parking_lot", "file": "core/src/word_lock.rs", "license": "MIT OR Apache-2.0"}] | ["code"] |
Promethean Rust Corpus V2
A curated Rust-focused corpus assembled from public source repositories, documentation, and programming exercises.
Current statistics
- Repository candidates: 113
- Repositories completed: 103
- Repositories skipped for license review: 9
- Raw extracted samples: 52,294
- Unique rows after exact-content deduplication: 51,642
- Initial target: 50,000 unique rows
Sample types
| Type | Unique rows |
|---|---|
| code | 45,910 |
| docs | 5,504 |
| exercise | 228 |
Largest contributing repositories
| Repository | Extracted samples before global deduplication |
|---|---|
astral-sh/ruff |
1,400 |
rust-lang/cargo |
1,400 |
wasm-bindgen/wasm-bindgen |
1,400 |
embassy-rs/embassy |
1,371 |
SeaQL/sea-orm |
1,325 |
DioxusLabs/dioxus |
1,324 |
leptos-rs/leptos |
1,320 |
esp-rs/esp-hal |
1,319 |
emilk/egui |
1,293 |
rust-lang/rust-analyzer |
1,281 |
nushell/nushell |
1,279 |
gfx-rs/wgpu |
1,276 |
rust-lang/rust-clippy |
1,273 |
tokio-rs/tokio |
1,269 |
zellij-org/zellij |
1,257 |
Dataset structure
The Parquet dataset contains:
text: the source code or documentation samplesample_type: code, docs, exercise, or mixedsource_repo: primary source repositorysource_file: primary source pathlicense: detected source license informationcontent_sha256: content hash used for exact deduplicationsource_count: number of source records associated with the rowsource_records_json: repository, path, and license provenance
Additional files:
repository_report.csv: extraction status and sample countssource_manifest.jsonl: source provenance for each unique sampledataset_metadata.json: machine-readable build statistics
Filtering and limitations
Repositories are checked against a conservative list of recognized permissive licenses. Repositories with unknown or ambiguous licenses are skipped for manual review.
Exact duplicate sample content is merged while preserving source provenance. Large repositories are capped to reduce source imbalance. Some generated files, oversized files, and samples matching common secret patterns are excluded.
The license field is repository-level metadata, not a legal determination that every file is covered by the same license. Individual files may have different terms. Review source licenses and attribution requirements before redistribution or commercial use.
This corpus is intended for research and model training. Its existence does not establish that training on every included sample is appropriate for every use.
Reproducibility
The repository candidate list, extraction settings, per-repository reports, content hashes, and source manifest should be retained with each release.
- Downloads last month
- 110