Skip to content

Commit

Permalink
Switch to crossbeam
Browse files Browse the repository at this point in the history
  • Loading branch information
carllin authored and jeffwashington committed Mar 30, 2021
1 parent 9b36bfd commit aa1f53b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions runtime/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use crate::{
contains::Contains,
};
use blake3::traits::digest::Digest;
use crossbeam_channel::{unbounded, Receiver, Sender};
use dashmap::{
mapref::entry::Entry::{Occupied, Vacant},
DashMap, DashSet,
Expand Down Expand Up @@ -57,7 +58,6 @@ use std::{
ops::{Range, RangeBounds},
path::{Path, PathBuf},
sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering},
sync::mpsc::{channel, Receiver, Sender},
sync::{Arc, Mutex, MutexGuard, RwLock},
thread::{Builder, JoinHandle},
time::Instant,
Expand Down Expand Up @@ -693,7 +693,7 @@ pub struct AccountsDb {

pub accounts_cache: AccountsCache,

sender_bg_hasher: Option<Mutex<Sender<CachedAccount>>>,
sender_bg_hasher: Option<Sender<CachedAccount>>,

recycle_stores: RwLock<RecycleStores>,

Expand Down Expand Up @@ -1324,14 +1324,14 @@ impl AccountsDb {
}

fn start_background_hasher(&mut self) {
let (sender, receiver) = channel();
let (sender, receiver) = unbounded();
Builder::new()
.name("solana-accounts-db-store-hasher".to_string())
.spawn(move || {
Self::background_hasher(receiver);
})
.unwrap();
self.sender_bg_hasher = Some(Mutex::new(sender));
self.sender_bg_hasher = Some(sender);
}

fn purge_keys_exact<'a, C: 'a>(
Expand Down Expand Up @@ -3420,7 +3420,7 @@ impl AccountsDb {
// hash this account in the bg
match &self.sender_bg_hasher {
Some(ref sender) => {
let _ = sender.lock().unwrap().send(cached_account);
let _ = sender.send(cached_account);
}
None => (),
};
Expand Down

0 comments on commit aa1f53b

Please sign in to comment.