Make mailbox push infallible and replace the locked tick-timing buffer with a lock-free ring. - channel: HybridChannel::push and Sender::send now return () — overflow always absorbs, never rejects — dropping the Result<(), T> surface and its callers. - stats: tick_timings moves from Mutex<VecDeque> to a lock-free crossbeam ArrayQueue (drop-oldest-on-full), removing the per-tick lock. - ripple the signature change through worker/runtime/config; drop worker_benchmarks. - expand runtime_api tests around the new channel/stats shapes. Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
28 lines
669 B
Rust
28 lines
669 B
Rust
/// Simple, ergonomic, local `Error` type.
|
|
/// # Usage
|
|
/// ```
|
|
/// use swactor::Error;
|
|
///
|
|
/// fn foo_if_even(num: u64) -> Result<String, Error> {
|
|
/// if num % 2 == 0 {
|
|
/// return Ok("foo".into());
|
|
/// }
|
|
/// else {
|
|
/// return Err(Error::from("baz"));
|
|
/// }
|
|
/// }
|
|
/// ```
|
|
#[derive(Debug)]
|
|
pub struct Error(Box<dyn std::error::Error + Send + Sync + 'static>);
|
|
|
|
impl<T: AsRef<str>> From<T> for Error {
|
|
fn from(value: T) -> Self {
|
|
Error(value.as_ref().to_string().into())
|
|
}
|
|
}
|
|
|
|
impl std::fmt::Display for Error {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
write!(f, "{}", self.0)
|
|
}
|
|
}
|