mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
perf: warm transactions in parallel (#13759)
This commit is contained in:
23
crates/revm/src/cancelled.rs
Normal file
23
crates/revm/src/cancelled.rs
Normal file
@ -0,0 +1,23 @@
|
||||
use alloc::sync::Arc;
|
||||
use core::sync::atomic::AtomicBool;
|
||||
|
||||
/// A marker that can be used to cancel execution.
|
||||
///
|
||||
/// If dropped, it will set the `cancelled` flag to true.
|
||||
#[derive(Default, Clone, Debug)]
|
||||
pub struct Cancelled(Arc<AtomicBool>);
|
||||
|
||||
// === impl Cancelled ===
|
||||
|
||||
impl Cancelled {
|
||||
/// Returns true if the job was cancelled.
|
||||
pub fn is_cancelled(&self) -> bool {
|
||||
self.0.load(core::sync::atomic::Ordering::Relaxed)
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Cancelled {
|
||||
fn drop(&mut self) {
|
||||
self.0.store(true, core::sync::atomic::Ordering::Relaxed);
|
||||
}
|
||||
}
|
||||
@ -17,6 +17,9 @@ pub mod batch;
|
||||
/// Database adapters for payload building.
|
||||
pub mod cached;
|
||||
|
||||
/// A marker that can be used to cancel execution.
|
||||
pub mod cancelled;
|
||||
|
||||
/// Contains glue code for integrating reth database into revm's [Database].
|
||||
pub mod database;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user