Skip to content

Commit

Permalink
More cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
carllin committed Oct 15, 2020
1 parent f5a4949 commit 74a3b4a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
18 changes: 12 additions & 6 deletions runtime/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1316,9 +1316,12 @@ impl AccountsDB {
let (slot, store_id, offset) = {
let (lock, index) = accounts_index.get(pubkey, Some(ancestors), None)?;
let slot_list = lock.slot_list();
let slot = slot_list[index].0;
let store_id = slot_list[index].1.store_id;
let offset = slot_list[index].1.offset;
let (
slot,
AccountInfo {
store_id, offset, ..
},
) = slot_list[index];
(slot, store_id, offset)
// `lock` released here
};
Expand All @@ -1342,9 +1345,12 @@ impl AccountsDB {
.get(pubkey, Some(ancestors), None)
.unwrap();
let slot_list = lock.slot_list();
let slot = slot_list[index].0;
let store_id = slot_list[index].1.store_id;
let offset = slot_list[index].1.offset;
let (
slot,
AccountInfo {
store_id, offset, ..
},
) = slot_list[index];
(slot, store_id, offset)
// lock released here
};
Expand Down
10 changes: 2 additions & 8 deletions runtime/src/accounts_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ use std::{
const ITER_BATCH_SIZE: usize = 1000;

#[self_referencing]
pub struct OwningReadGuard<T>
where
T: 'static,
{
pub struct OwningReadGuard<T: 'static> {
lock: Arc<RwLock<T>>,
#[borrows(lock)]
pub guard: RwLockReadGuard<'this, T>,
Expand All @@ -30,10 +27,7 @@ impl<T> Deref for OwningReadGuard<T> {
}

#[self_referencing]
pub struct OwningWriteGuard<T>
where
T: 'static,
{
pub struct OwningWriteGuard<T: 'static> {
lock: Arc<RwLock<T>>,
#[borrows(lock)]
pub guard: RwLockWriteGuard<'this, T>,
Expand Down

0 comments on commit 74a3b4a

Please sign in to comment.