repo stringclasses 7
values | lang stringclasses 2
values | aspect stringclasses 7
values | file stringlengths 5 48 | content stringlengths 283 144k |
|---|---|---|---|---|
arrow-rs | rust | columnar | list_array.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use crate::arrow::array_re... |
arrow-rs | rust | columnar | fixed_len_byte_array.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use crate::arrow::array_re... |
arrow-rs | rust | columnar | map_array.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use crate::arrow::array_re... |
arrow-rs | rust | columnar | mod.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use crate::errors::Result... |
arrow-rs | rust | columnar | empty_array.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use crate::arrow::array_re... |
arrow-rs | rust | columnar | list_view_array.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use crate::arrow::array_re... |
arrow-rs | rust | columnar | fixed_size_list_array.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use std::sync::Arc;
use c... |
arrow-rs | rust | columnar | struct_array.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use crate::arrow::array_re... |
arrow-rs | rust | columnar | primitive_array.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use crate::arrow::array_re... |
arrow-rs | rust | columnar | null_array.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use crate::arrow::array_re... |
arrow-rs | rust | columnar | builder.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use std::sync::{Arc, RwLoc... |
arrow-rs | rust | columnar | byte_array.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use crate::arrow::array_re... |
arrow-rs | rust | columnar | levels.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use crate::column::chunke... |
arrow-rs | rust | columnar | byte_array.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use crate::basic::Encoding... |
arrow-rs | rust | columnar | store.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use bytes::Bytes;
use futu... |
arrow-rs | rust | columnar | mod.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
#[cfg(feature = "object_s... |
arrow-rs | rust | columnar | offset_buffer.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use crate::arrow::buffer::... |
arrow-rs | rust | columnar | bit_util.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use arrow_buffer::bit_chun... |
arrow-rs | rust | columnar | view_buffer.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use crate::arrow::record_r... |
arrow-rs | rust | columnar | dictionary_buffer.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use crate::arrow::buffer::... |
arrow-rs | rust | columnar | page.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use bytes::Bytes;
use cr... |
arrow-rs | rust | columnar | page_encryption_disabled.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
// The methods below mirro... |
arrow-rs | rust | columnar | page_store.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use std::fmt::Debug;
use... |
arrow-rs | rust | columnar | mod.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
#[cfg(feature = "arrow")]... |
arrow-rs | rust | columnar | page_encryption.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use crate::basic::PageType... |
arrow-rs | rust | columnar | reader.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use bytes::Bytes;
use su... |
arrow-rs | rust | columnar | decoder.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use bytes::Bytes;
use cra... |
arrow-rs | rust | columnar | legacy_fixed_len_byte_array.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use bytes::Bytes;
use su... |
arrow-rs | rust | columnar | encoder.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use bytes::Bytes;
use cra... |
arrow-rs | rust | columnar | byte_budget_chunker.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use crate::basic::Type;
u... |
arrow-rs | rust | columnar | cdc.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
#[cfg(feature = "arrow")]
... |
arrow-rs | rust | columnar | mod.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
mod cdc;
mod cdc_generate... |
arrow-rs | rust | columnar | types.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use std::vec::IntoIter;
u... |
arrow-rs | rust | columnar | printer.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use std::{fmt, io};
use ... |
arrow-rs | rust | columnar | parser.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use std::sync::Arc;
use ... |
arrow-rs | rust | columnar | visitor.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use crate::basic::{Conver... |
arrow-rs | rust | columnar | mod.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
#[cfg(all(feature = "arro... |
arrow-rs | rust | columnar | push.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use std::ops::Range;
use... |
arrow-rs | rust | columnar | statistics.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use crate::{file::metadat... |
arrow-rs | rust | columnar | accumulator.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use std::sync::{Arc, Once... |
arrow-rs | rust | columnar | bounding_box.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use crate::file::metadata... |
arrow-rs | rust | columnar | types.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use arrow_schema::{ArrowEr... |
arrow-rs | rust | columnar | lib.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
pub mod bounding;
pub mod... |
arrow-rs | rust | columnar | interval.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use arrow_schema::ArrowErr... |
arrow-rs | rust | columnar | bounding.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use std::collections::Hash... |
arrow-rs | rust | columnar | lib.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
#![doc(
html_logo_url... |
arrow-rs | rust | columnar | parquet_field.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use syn::ext::IdentExt;
/... |
arrow-rs | rust | columnar | dict_cmp.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
use std::hint::black_box;
... |
arrow-rs | rust | columnar | lib.rs | // SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
#![deny(rustdoc::broken_i... |
crossbeam | rust | concurrency | build.rs | // The rustc-cfg emitted by the build script are *not* public API.
use std::env;
fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rustc-check-cfg=cfg(crossbeam_sanitize_thread)");
let target = &*env::var("TARGET").expect("TARGET not set");
// `cfg(sanitize = "..")` is not sta... |
crossbeam | rust | concurrency | loom.rs | // Put in module instead of using #![cfg(..)] to work around rustc/cargo bug around -Z crate-attr.
#[cfg(crossbeam_loom)]
mod tests {
use std::{mem::ManuallyDrop, ptr};
use crossbeam_epoch as epoch;
use epoch::{Atomic, Owned, *};
use loom::{
sync::{
Arc,
atomic::Ordering... |
crossbeam | rust | concurrency | sanitize.rs | use std::{
sync::{
Arc,
atomic::{
AtomicUsize,
Ordering::{AcqRel, Acquire, Relaxed},
},
},
thread,
time::{Duration, Instant},
};
use crossbeam_epoch::{self as epoch, Atomic, Collector, LocalHandle, Owned, Shared};
fn worker(a: Arc<Atomic<AtomicUsize>>, h... |
crossbeam | rust | concurrency | pin.rs | #![feature(test)]
extern crate test;
use crossbeam_epoch as epoch;
use crossbeam_utils::thread::scope;
use test::Bencher;
#[bench]
fn single_pin(b: &mut Bencher) {
b.iter(epoch::pin);
}
#[bench]
fn multi_pin(b: &mut Bencher) {
const THREADS: usize = 16;
const STEPS: usize = 100_000;
b.iter(|| {
... |
crossbeam | rust | concurrency | defer.rs | #![feature(test)]
extern crate test;
use crossbeam_epoch::{self as epoch, Owned};
use crossbeam_utils::thread::scope;
use test::Bencher;
#[bench]
fn single_alloc_defer_free(b: &mut Bencher) {
b.iter(|| {
let guard = &epoch::pin();
let p = Owned::new(1).into_shared(guard);
unsafe {
... |
crossbeam | rust | concurrency | flush.rs | #![feature(test)]
extern crate test;
use std::sync::Barrier;
use crossbeam_epoch as epoch;
use crossbeam_utils::thread::scope;
use test::Bencher;
#[bench]
fn single_flush(b: &mut Bencher) {
const THREADS: usize = 16;
let start = Barrier::new(THREADS + 1);
let end = Barrier::new(THREADS + 1);
scope... |
crossbeam | rust | concurrency | collector.rs | /// Epoch-based garbage collector.
///
/// # Examples
///
/// ```
/// use crossbeam_epoch::Collector;
///
/// let collector = Collector::new();
///
/// let handle = collector.register();
/// drop(collector); // `handle` still works after dropping `collector`
///
/// handle.pin().flush();
/// ```
use core::fmt;
use cra... |
crossbeam | rust | concurrency | lib.rs | #![no_std]
#![doc(test(
no_crate_inject,
attr(allow(dead_code, unused_assignments, unused_variables))
))]
#![warn(
missing_docs,
unsafe_op_in_unsafe_fn,
clippy::alloc_instead_of_core,
clippy::std_instead_of_alloc,
clippy::std_instead_of_core
)]
#[cfg(crossbeam_loom)]
extern crate loom_crate... |
crossbeam | rust | concurrency | internal.rs | use core::{
cell::Cell,
fmt,
mem::{self, ManuallyDrop},
num::Wrapping,
ptr,
};
use crossbeam_utils::CachePadded;
use crate::{
atomic::{Owned, Shared},
collector::{Collector, LocalHandle},
deferred::Deferred,
epoch::{AtomicEpoch, Epoch},
guard::{Guard, unprotected},
primitiv... |
crossbeam | rust | concurrency | atomic.rs | use alloc::boxed::Box;
use core::{
alloc::Layout,
borrow::{Borrow, BorrowMut},
cmp, fmt,
marker::PhantomData,
mem::{self, MaybeUninit},
ops::{Deref, DerefMut},
ptr::{self, NonNull},
};
use crossbeam_utils::atomic::AtomicConsume;
#[cfg(not(miri))]
use crate::primitive::sync::atomic::AtomicU... |
crossbeam | rust | concurrency | guard.rs | use core::{fmt, mem};
use crate::{
atomic::{Pointable, Shared},
collector::Collector,
deferred::Deferred,
internal::Local,
};
/// A guard that keeps the current thread pinned.
///
/// # Pinning
///
/// The current thread is pinned by calling [`pin`], which returns a new guard:
///
/// ```
/// use cros... |
crossbeam | rust | concurrency | default.rs | #[cfg(not(crossbeam_loom))]
use std::sync::OnceLock;
use crate::{
collector::{Collector, LocalHandle},
guard::Guard,
primitive::thread_local,
};
fn collector() -> &'static Collector {
#[cfg(not(crossbeam_loom))]
{
/// The global data for the default garbage collector.
static COLLEC... |
crossbeam | rust | concurrency | alloc_helper.rs | use core::{alloc::Layout, ptr::NonNull};
// Based on unstable alloc::alloc::Global.
//
// Note: unlike alloc::alloc::Global that returns NonNull<[u8]>,
// this returns NonNull<u8>.
pub(crate) struct Global;
#[allow(clippy::unused_self)]
impl Global {
#[inline]
#[cfg_attr(miri, track_caller)] // even without pa... |
crossbeam | rust | concurrency | epoch.rs | use crate::primitive::sync::atomic::Ordering;
// Ideally, we want to always use AtomicU64, but since it is not available on all platforms,
// we only use it when it is available for now.
// TODO: On platforms where AtomicU64 is unavailable, we may want to use AtomicCell instead of
// AtomicUsize. (https://github.com/c... |
crossbeam | rust | concurrency | deferred.rs | use alloc::boxed::Box;
use core::{
fmt,
marker::PhantomData,
mem::{self, MaybeUninit},
ptr,
};
/// Number of words a piece of `Data` can hold.
///
/// Three words should be enough for the majority of cases. For example, you can fit inside it the
/// function pointer together with a fat pointer represen... |
crossbeam | rust | concurrency | list.rs | use core::{
marker::PhantomData,
ptr::NonNull,
sync::atomic::Ordering::{Acquire, Relaxed, Release},
};
use crate::{Atomic, Guard, Shared, unprotected};
/// An entry in a linked list.
///
/// An Entry is accessed from multiple threads, so it would be beneficial to put it in a different
/// cache-line than ... |
crossbeam | rust | concurrency | queue.rs | use core::{
mem::MaybeUninit,
sync::atomic::Ordering::{Acquire, Relaxed, Release},
};
use crossbeam_utils::CachePadded;
use crate::{Atomic, Guard, Owned, Shared, unprotected};
// The representation here is a singly-linked list, with a sentinel node at the front. In general
// the `tail` pointer may lag behin... |
crossbeam | rust | concurrency | build.rs | // The rustc-cfg emitted by the build script are *not* public API.
use std::env;
fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!(
"cargo:rustc-check-cfg=cfg(crossbeam_sanitize_thread,crossbeam_atomic_cell_force_fallback)"
);
let target = &*env::var("TARGET").expect("TARGET n... |
crossbeam | rust | concurrency | wait_group.rs | use std::{sync::mpsc, thread, time::Duration};
use crossbeam_utils::sync::WaitGroup;
const THREADS: usize = 10;
#[test]
fn wait() {
let wg = WaitGroup::new();
let (tx, rx) = mpsc::channel();
for _ in 0..THREADS {
let wg = wg.clone();
let tx = tx.clone();
thread::spawn(move || {
... |
crossbeam | rust | concurrency | sharded_lock.rs | use std::{
mem,
sync::{
Arc, TryLockError,
atomic::{AtomicUsize, Ordering},
mpsc::channel,
},
thread,
};
use crossbeam_utils::sync::ShardedLock;
#[derive(Eq, PartialEq, Debug)]
struct NonCopy(i32);
#[test]
fn smoke() {
let l = ShardedLock::new(());
drop(l.read().unwrap... |
crossbeam | rust | concurrency | thread.rs | use std::{
any::Any,
sync::atomic::{AtomicUsize, Ordering},
thread::sleep,
time::Duration,
};
use crossbeam_utils::thread;
const THREADS: usize = 10;
const SMALL_STACK_SIZE: usize = 20;
#[test]
fn join() {
let counter = AtomicUsize::new(0);
thread::scope(|scope| {
let handle = scope.s... |
crossbeam | rust | concurrency | cache_padded.rs | use std::{cell::Cell, mem};
use crossbeam_utils::CachePadded;
#[test]
fn default() {
let x: CachePadded<u64> = Default::default();
assert_eq!(*x, 0);
}
#[test]
fn store_u64() {
let x: CachePadded<u64> = CachePadded::new(17);
assert_eq!(*x, 17);
}
#[test]
fn store_pair() {
let x: CachePadded<(u64... |
crossbeam | rust | concurrency | atomic_cell.rs | use std::{
mem,
sync::atomic::{AtomicUsize, Ordering::SeqCst},
};
use crossbeam_utils::atomic::AtomicCell;
// Always use fallback for now on environments that do not support inline assembly.
fn always_use_fallback() -> bool {
atomic_maybe_uninit::cfg_has_atomic_cas! {
cfg!(any(
miri,
... |
crossbeam | rust | concurrency | parker.rs | use std::{thread::sleep, time::Duration};
use crossbeam_utils::{
sync::{Parker, UnparkReason},
thread,
};
#[test]
fn park_timeout_unpark_before() {
let p = Parker::new();
for _ in 0..10 {
p.unparker().unpark();
assert_eq!(
p.park_timeout(Duration::from_millis(u32::MAX as u6... |
crossbeam | rust | concurrency | atomic_cell.rs | #![feature(test)]
extern crate test;
use std::sync::Barrier;
use crossbeam_utils::{atomic::AtomicCell, thread};
#[bench]
fn load_u8(b: &mut test::Bencher) {
let a = AtomicCell::new(0u8);
let mut sum = 0;
b.iter(|| sum += a.load());
test::black_box(sum);
}
#[bench]
fn store_u8(b: &mut test::Bencher)... |
crossbeam | rust | concurrency | backoff.rs | use core::{cell::Cell, fmt};
use crate::primitive::hint;
const SPIN_LIMIT: u32 = 6;
const YIELD_LIMIT: u32 = 10;
/// Performs exponential backoff in spin loops.
///
/// Backing off in spin loops reduces contention and improves overall performance.
///
/// This primitive can execute *YIELD* and *PAUSE* instructions, ... |
crossbeam | rust | concurrency | thread.rs | use alloc::{boxed::Box, string::String, sync::Arc, vec::Vec};
use core::{fmt, marker::PhantomData, mem};
use std::{io, panic, sync::Mutex, thread};
use crate::sync::WaitGroup;
type SharedVec<T> = Arc<Mutex<Vec<T>>>;
type SharedOption<T> = Arc<Mutex<Option<T>>>;
/// Creates a new scope for spawning threads.
///
/// A... |
crossbeam | rust | concurrency | cache_padded.rs | use core::{
fmt,
ops::{Deref, DerefMut},
};
/// Pads and aligns a value to the length of a cache line.
///
/// In concurrent programming, sometimes it is desirable to make sure commonly accessed pieces of
/// data are not placed into the same cache line. Updating an atomic value invalidates the whole
/// cache... |
crossbeam | rust | concurrency | lib.rs | #![no_std]
#![doc(test(
no_crate_inject,
attr(allow(dead_code, unused_assignments, unused_variables))
))]
#![warn(
missing_docs,
unsafe_op_in_unsafe_fn,
clippy::alloc_instead_of_core,
clippy::std_instead_of_alloc,
clippy::std_instead_of_core
)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#[cfg(f... |
crossbeam | rust | concurrency | alloc_helper.rs | use core::{alloc::Layout, ptr::NonNull};
// Based on unstable alloc::alloc::Global.
//
// Note: unlike alloc::alloc::Global that returns NonNull<[u8]>,
// this returns NonNull<u8>.
pub(crate) struct Global;
#[allow(clippy::unused_self)]
impl Global {
#[inline]
#[cfg_attr(miri, track_caller)] // even without pa... |
crossbeam | rust | concurrency | seq_lock_wide.rs | use core::{
mem,
sync::atomic::{self, AtomicUsize, Ordering},
};
use crate::Backoff;
/// A simple stamped lock.
///
/// The state is represented as two `AtomicUsize`: `state_hi` for high bits and `state_lo` for low
/// bits.
pub(crate) struct SeqLock {
/// The high bits of the current state of the lock.
... |
crossbeam | rust | concurrency | atomic_cell.rs | // Necessary for implementing atomic methods for `AtomicUnit`
#![allow(clippy::unit_arg)]
use core::{
cell::UnsafeCell,
cmp, fmt,
mem::{self, ManuallyDrop, MaybeUninit},
panic::{RefUnwindSafe, UnwindSafe},
ptr,
};
use super::seq_lock::SeqLock;
use crate::{
CachePadded,
primitive::sync::ato... |
crossbeam | rust | concurrency | mod.rs | #[cfg(target_has_atomic = "ptr")]
#[cfg(not(crossbeam_loom))]
// Use "wide" sequence lock if the pointer width <= 32 for preventing its counter against wrap
// around.
//
// In narrow architectures (pointer width <= 16), the counter is still <= 32-bit and may be
// vulnerable to wrap around. But it's mostly okay, since... |
crossbeam | rust | concurrency | consume.rs | // TODO: use target_has_atomic_load_store once stabilized.
#[cfg(target_has_atomic = "ptr")]
use core::sync::atomic::Ordering;
/// Trait which allows reading from primitive atomic types with "consume" ordering.
pub trait AtomicConsume {
/// Type returned by `load_consume`.
type Val;
/// Loads a value fro... |
crossbeam | rust | concurrency | seq_lock.rs | use core::{
mem,
sync::atomic::{self, AtomicUsize, Ordering},
};
use crate::Backoff;
/// A simple stamped lock.
pub(crate) struct SeqLock {
/// The current state of the lock.
///
/// All bits except the least significant one hold the current stamp. When locked, the state
/// equals 1 and doesn... |
crossbeam | rust | concurrency | wait_group.rs | use core::{fmt, mem::ManuallyDrop};
use crate::primitive::sync::{
Arc, Condvar, Mutex,
atomic::{AtomicUsize, Ordering},
};
/// Enables threads to synchronize the beginning or end of some computation.
///
/// # Wait groups vs barriers
///
/// `WaitGroup` is very similar to [`Barrier`], but there are a few diff... |
crossbeam | rust | concurrency | sharded_lock.rs | use alloc::{boxed::Box, vec::Vec};
use core::{
cell::UnsafeCell,
fmt,
marker::PhantomData,
mem::{self, MaybeUninit},
ops::{Deref, DerefMut},
panic::{RefUnwindSafe, UnwindSafe},
};
use std::{
collections::HashMap,
sync::{
LockResult, Mutex, PoisonError, RwLock, RwLockReadGuard, Rw... |
crossbeam | rust | concurrency | once_lock.rs | // Based on unstable std::sync::OnceLock.
//
// Source: https://github.com/rust-lang/rust/blob/8e9c93df464b7ada3fc7a1c8ccddd9dcb24ee0a0/library/std/src/sync/once_lock.rs
use core::{cell::UnsafeCell, mem::MaybeUninit};
use std::sync::Once;
pub(crate) struct OnceLock<T> {
once: Once,
value: UnsafeCell<MaybeUnin... |
crossbeam | rust | concurrency | parker.rs | use core::{fmt, marker::PhantomData, time::Duration};
use std::time::Instant;
use crate::primitive::sync::{
Arc, Condvar, Mutex,
atomic::{AtomicUsize, Ordering::SeqCst},
};
/// A thread parking primitive.
///
/// Conceptually, each `Parker` has an associated token which is initially not present:
///
/// * The... |
crossbeam | rust | concurrency | same_channel.rs | #![allow(clippy::redundant_clone)]
use std::time::Duration;
use crossbeam_channel::{after, bounded, never, tick, unbounded};
fn ms(ms: u64) -> Duration {
Duration::from_millis(ms)
}
#[test]
fn after_same_channel() {
let r = after(ms(50));
let r2 = r.clone();
assert!(r.same_channel(&r2));
let r... |
crossbeam | rust | concurrency | zero.rs | use std::{
any::Any,
sync::atomic::{AtomicUsize, Ordering},
thread,
time::Duration,
};
use crossbeam_channel::{
Receiver, RecvError, RecvTimeoutError, SendError, SendTimeoutError, TryRecvError, TrySendError,
bounded, select,
};
use crossbeam_utils::thread::scope;
fn ms(ms: u64) -> Duration {
... |
crossbeam | rust | concurrency | after.rs | #![cfg(not(miri))] // TODO: many assertions failed due to Miri is slow
use std::{
sync::atomic::{AtomicUsize, Ordering},
thread,
time::{Duration, Instant},
};
use crossbeam_channel::{Select, TryRecvError, after, select};
use crossbeam_utils::thread::scope;
fn ms(ms: u64) -> Duration {
Duration::from_... |
crossbeam | rust | concurrency | never.rs | use std::{
thread,
time::{Duration, Instant},
};
use crossbeam_channel::{never, select, tick, unbounded};
fn ms(ms: u64) -> Duration {
Duration::from_millis(ms)
}
#[test]
fn smoke() {
select! {
recv(never::<i32>()) -> _ => panic!(),
default => {}
}
}
#[test]
fn optional() {
l... |
crossbeam | rust | concurrency | list.rs | use std::{
any::Any,
sync::atomic::{AtomicUsize, Ordering},
thread,
time::Duration,
};
use crossbeam_channel::{
Receiver, RecvError, RecvTimeoutError, SendError, SendTimeoutError, TryRecvError, TrySendError,
select, unbounded,
};
use crossbeam_utils::thread::scope;
fn ms(ms: u64) -> Duration {... |
crossbeam | rust | concurrency | iter.rs | use crossbeam_channel::unbounded;
use crossbeam_utils::thread::scope;
#[test]
fn nested_recv_iter() {
let (s, r) = unbounded::<i32>();
let (total_s, total_r) = unbounded::<i32>();
scope(|scope| {
scope.spawn(move |_| {
let mut acc = 0;
for x in r.iter() {
ac... |
crossbeam | rust | concurrency | mpsc.rs | #![allow(clippy::match_single_binding, clippy::redundant_clone)]
use std::{
sync::mpsc::{RecvError, RecvTimeoutError, SendError, TryRecvError, TrySendError},
thread::JoinHandle,
time::Duration,
};
use crossbeam_channel as cc;
struct Sender<T> {
inner: cc::Sender<T>,
}
impl<T> Sender<T> {
fn send... |
crossbeam | rust | concurrency | select_macro.rs | #![forbid(unsafe_code)] // select! is safe.
#![allow(clippy::match_single_binding)]
use std::{
any::Any,
cell::Cell,
ops::Deref,
thread,
time::{Duration, Instant},
};
use crossbeam_channel::{
Receiver, RecvError, SendError, Sender, TryRecvError, after, bounded, never, select,
select_biased... |
crossbeam | rust | concurrency | select.rs | use std::{
any::Any,
cell::Cell,
mem,
sync::{
Arc, Barrier,
atomic::{AtomicBool, Ordering},
},
thread,
time::{Duration, Instant},
};
use crossbeam_channel::{Receiver, Select, TryRecvError, after, bounded, tick, unbounded};
use crossbeam_utils::thread::scope;
fn ms(ms: u64) ... |
crossbeam | rust | concurrency | array.rs | use std::{
any::Any,
rc::Rc,
sync::atomic::{AtomicUsize, Ordering},
thread,
time::Duration,
};
use crossbeam_channel::{
Receiver, RecvError, RecvTimeoutError, SendError, SendTimeoutError, TryRecvError, TrySendError,
bounded, select,
};
use crossbeam_utils::thread::scope;
fn ms(ms: u64) -> ... |
crossbeam | rust | concurrency | golang.rs | #![allow(clippy::redundant_clone)]
use std::{
alloc::{GlobalAlloc, Layout, System},
any::Any,
cell::Cell,
collections::HashMap,
sync::{
Arc, Condvar, Mutex,
atomic::{AtomicI32, AtomicUsize, Ordering::SeqCst},
},
thread,
time::Duration,
};
use crossbeam_channel::{Receive... |
crossbeam | rust | concurrency | tick.rs | #![cfg(not(miri))] // TODO: many assertions failed due to Miri is slow
use std::{
sync::atomic::{AtomicUsize, Ordering},
thread,
time::{Duration, Instant},
};
use crossbeam_channel::{Select, TryRecvError, after, select, tick};
use crossbeam_utils::thread::scope;
fn ms(ms: u64) -> Duration {
Duration:... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.