swactor/src/error.rs
zacheryasc 74b92d71ab refactor(core): lock-free tick timings, infallible channel push (#28)
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>
2026-02-10 07:35:58 +00:00

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)
}
}