#![warn(missing_docs)]
pub mod align;
pub mod backoff;
pub mod bench_harness;
pub(crate) mod block;
pub(crate) mod queue;
#[cfg(test)]
mod tests;
pub use block::BLOCK_LENGTH;
pub use queue::{ConfiguredUBQ, DEFAULT_POOL_SIZE};
pub type UBQ<T> = ConfiguredUBQ<T>;
#[doc(hidden)]
#[macro_export]
macro_rules! __ubq_align_for_block {
(31) => {
$crate::align::A64
};
(63) => {
$crate::align::A128
};
(127) => {
$crate::align::A256
};
(255) => {
$crate::align::A512
};
(511) => {
$crate::align::A1024
};
(1023) => {
$crate::align::A2048
};
(2047) => {
$crate::align::A4096
};
(4095) => {
$crate::align::A8192
};
($other:expr) => {
compile_error!(
"ubq! requires an explicit `align:` when `block:` is not one of 31, 63, 127, 255, 511, 1023, 2047, or 4095"
)
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __ubq_internal {
(
@parse
type = $ty:ty,
backoff = $backoff:path,
pool = $pool:tt,
block = $block:tt,
align = [];
$(,)?
) => {
$crate::ConfiguredUBQ::<
$ty,
$backoff,
{ $pool },
{ $block },
$crate::__ubq_align_for_block!($block)
>::new()
};
(
@parse
type = $ty:ty,
backoff = $backoff:path,
pool = $pool:tt,
block = $block:tt,
align = [$align:path];
$(,)?
) => {
$crate::ConfiguredUBQ::<$ty, $backoff, { $pool }, { $block }, $align>::new()
};
(
@parse
type = $ty:ty,
backoff = $backoff:path,
pool = $pool:tt,
block = $block:tt,
align = [$($align:tt)*];
backoff: $new_backoff:path $(, $($rest:tt)*)?
) => {
$crate::__ubq_internal!(
@parse
type = $ty,
backoff = $new_backoff,
pool = $pool,
block = $block,
align = [$($align)*];
$($($rest)*)?
)
};
(
@parse
type = $ty:ty,
backoff = $backoff:path,
pool = $pool:tt,
block = $block:tt,
align = [$($align:tt)*];
pool: $new_pool:tt $(, $($rest:tt)*)?
) => {
$crate::__ubq_internal!(
@parse
type = $ty,
backoff = $backoff,
pool = $new_pool,
block = $block,
align = [$($align)*];
$($($rest)*)?
)
};
(
@parse
type = $ty:ty,
backoff = $backoff:path,
pool = $pool:tt,
block = $block:tt,
align = [$($align:tt)*];
block: $new_block:tt $(, $($rest:tt)*)?
) => {
$crate::__ubq_internal!(
@parse
type = $ty,
backoff = $backoff,
pool = $pool,
block = $new_block,
align = [$($align)*];
$($($rest)*)?
)
};
(
@parse
type = $ty:ty,
backoff = $backoff:path,
pool = $pool:tt,
block = $block:tt,
align = [$($align:tt)*];
align: $new_align:path $(, $($rest:tt)*)?
) => {
$crate::__ubq_internal!(
@parse
type = $ty,
backoff = $backoff,
pool = $pool,
block = $block,
align = [$new_align];
$($($rest)*)?
)
};
(
@parse
type = $ty:ty,
backoff = $backoff:path,
pool = $pool:tt,
block = $block:tt,
align = [$($align:tt)*];
$unknown:ident : $value:tt $(, $($rest:tt)*)?
) => {
compile_error!(concat!("unsupported ubq! option `", stringify!($unknown), "`"));
};
}
#[macro_export]
macro_rules! ubq {
(type: $ty:ty $(, $($rest:tt)*)?) => {
$crate::__ubq_internal!(
@parse
type = $ty,
backoff = $crate::backoff::Crossbeam,
pool = 1,
block = 2047,
align = [];
$($($rest)*)?
)
};
}