mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: name std threads (#8475)
This commit is contained in:
@ -45,14 +45,14 @@ impl TxnManager {
|
||||
txn_manager
|
||||
}
|
||||
|
||||
/// Spawns a new thread with [std::thread::spawn] that listens to incoming [TxnManagerMessage]
|
||||
/// messages, executes an FFI function, and returns the result on the provided channel.
|
||||
/// Spawns a new [std::thread] that listens to incoming [TxnManagerMessage] messages, executes
|
||||
/// an FFI function, and returns the result on the provided channel.
|
||||
///
|
||||
/// - [TxnManagerMessage::Begin] opens a new transaction with [ffi::mdbx_txn_begin_ex]
|
||||
/// - [TxnManagerMessage::Abort] aborts a transaction with [ffi::mdbx_txn_abort]
|
||||
/// - [TxnManagerMessage::Commit] commits a transaction with [ffi::mdbx_txn_commit_ex]
|
||||
fn start_message_listener(&self, env: EnvPtr, rx: Receiver<TxnManagerMessage>) {
|
||||
std::thread::spawn(move || {
|
||||
let task = move || {
|
||||
#[allow(clippy::redundant_locals)]
|
||||
let env = env;
|
||||
loop {
|
||||
@ -90,7 +90,8 @@ impl TxnManager {
|
||||
Err(_) => return,
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
std::thread::Builder::new().name("mbdx-rs-txn-manager".to_string()).spawn(task).unwrap();
|
||||
}
|
||||
|
||||
pub(crate) fn send_message(&self, message: TxnManagerMessage) {
|
||||
@ -198,11 +199,10 @@ mod read_transactions {
|
||||
self.timed_out_not_aborted.len()
|
||||
}
|
||||
|
||||
/// Spawns a new thread with [std::thread::spawn] that monitors the list of active read
|
||||
/// transactions and timeouts those that are open for longer than
|
||||
/// `ReadTransactions.max_duration`.
|
||||
/// Spawns a new [std::thread] that monitors the list of active read transactions and
|
||||
/// timeouts those that are open for longer than `ReadTransactions.max_duration`.
|
||||
pub(super) fn start_monitor(self: Arc<Self>) {
|
||||
std::thread::spawn(move || {
|
||||
let task = move || {
|
||||
let mut timed_out_active = Vec::new();
|
||||
|
||||
loop {
|
||||
@ -295,7 +295,11 @@ mod read_transactions {
|
||||
READ_TRANSACTIONS_CHECK_INTERVAL.min(duration_until_closest_deadline),
|
||||
);
|
||||
}
|
||||
});
|
||||
};
|
||||
std::thread::Builder::new()
|
||||
.name("mdbx-rs-read-tx-timeouts".to_string())
|
||||
.spawn(task)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user