This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![allow(unused)] | |
use std::any::Any; | |
use std::marker::PhantomData; | |
struct NumericAttr<T> { | |
_m: PhantomData<T>, | |
} | |
impl<T> NumericAttr<T> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This will spawn 2 producer threads which will try to keep up to NUM_SESSIONS Sessions available for consumers | |
use flume::Receiver; | |
use once_cell::sync::OnceCell; | |
#[derive(Debug, Clone)] | |
struct Session; | |
const NUM_SESSIONS: usize = 10; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Parallel iterator over a contiguous array of i32 values given a raw pointer and size; | |
use rayon::prelude::*; | |
fn var_1(ptr: *mut i32, len: usize) { | |
// With a stdlib slice | |
let data_sl = unsafe { std::slice::from_raw_parts_mut(ptr, len) }; | |
data_sl.into_par_iter().for_each(|i| *i *= *i); | |
} |