Skip to content

Commit

Permalink
Refactor: Same approach for cached_statements_size
Browse files Browse the repository at this point in the history
ref: a66787d
  • Loading branch information
mpyw committed Aug 12, 2024
1 parent a66787d commit 54c73b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 1 addition & 4 deletions sqlx-sqlite/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,7 @@ impl Connection for SqliteConnection {
}

fn cached_statements_size(&self) -> usize {
self.worker
.shared
.cached_statements_size
.load(std::sync::atomic::Ordering::Acquire)
self.worker.shared.get_cached_statements_size()
}

fn clear_cached_statements(&mut self) -> BoxFuture<'_, Result<(), Error>> {
Expand Down
6 changes: 5 additions & 1 deletion sqlx-sqlite/src/connection/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,18 @@ pub(crate) struct ConnectionWorker {

pub(crate) struct WorkerSharedState {
transaction_depth: AtomicUsize,
pub(crate) cached_statements_size: AtomicUsize,
cached_statements_size: AtomicUsize,
pub(crate) conn: Mutex<ConnectionState>,
}

impl WorkerSharedState {
pub(crate) fn get_transaction_depth(&self) -> usize {
self.transaction_depth.load(Ordering::Acquire)
}

pub(crate) fn get_cached_statements_size(&self) -> usize {
self.cached_statements_size.load(Ordering::Acquire)
}
}

enum Command {
Expand Down

0 comments on commit 54c73b6

Please sign in to comment.