breaking(pool): use usize for all connection counts

This commit is contained in:
Austin Bonander 2024-10-18 19:48:44 -07:00
parent 54564bead6
commit 0601c3a75d
3 changed files with 11 additions and 11 deletions

View File

@ -11,7 +11,7 @@ use crate::sync::{AsyncSemaphore, AsyncSemaphoreReleaser};
use std::cmp;
use std::future::{self, Future};
use std::pin::pin;
use std::sync::atomic::{AtomicBool, AtomicU32, AtomicUsize, Ordering};
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::sync::{Arc, RwLock};
use std::task::Poll;
@ -26,7 +26,7 @@ pub(crate) struct PoolInner<DB: Database> {
pub(super) connect_options: RwLock<Arc<<DB::Connection as Connection>::Options>>,
pub(super) idle_conns: ArrayQueue<Idle<DB>>,
pub(super) semaphore: AsyncSemaphore,
pub(super) size: AtomicU32,
pub(super) size: AtomicUsize,
pub(super) num_idle: AtomicUsize,
is_closed: AtomicBool,
pub(super) on_closed: event_listener::Event,
@ -55,7 +55,7 @@ impl<DB: Database> PoolInner<DB> {
connect_options: RwLock::new(Arc::new(connect_options)),
idle_conns: ArrayQueue::new(capacity),
semaphore: AsyncSemaphore::new(options.fair, semaphore_capacity),
size: AtomicU32::new(0),
size: AtomicUsize::new(0),
num_idle: AtomicUsize::new(0),
is_closed: AtomicBool::new(false),
on_closed: event_listener::Event::new(),
@ -71,7 +71,7 @@ impl<DB: Database> PoolInner<DB> {
pool
}
pub(super) fn size(&self) -> u32 {
pub(super) fn size(&self) -> usize {
self.size.load(Ordering::Acquire)
}

View File

@ -532,7 +532,7 @@ impl<DB: Database> Pool<DB> {
}
/// Returns the number of connections currently active. This includes idle connections.
pub fn size(&self) -> u32 {
pub fn size(&self) -> usize {
self.0.size()
}

View File

@ -74,12 +74,12 @@ pub struct PoolOptions<DB: Database> {
+ Sync,
>,
>,
pub(crate) max_connections: u32,
pub(crate) max_connections: usize,
pub(crate) acquire_time_level: LevelFilter,
pub(crate) acquire_slow_level: LevelFilter,
pub(crate) acquire_slow_threshold: Duration,
pub(crate) acquire_timeout: Duration,
pub(crate) min_connections: u32,
pub(crate) min_connections: usize,
pub(crate) max_lifetime: Option<Duration>,
pub(crate) idle_timeout: Option<Duration>,
pub(crate) fair: bool,
@ -170,13 +170,13 @@ impl<DB: Database> PoolOptions<DB> {
/// Be mindful of the connection limits for your database as well as other applications
/// which may want to connect to the same database (or even multiple instances of the same
/// application in high-availability deployments).
pub fn max_connections(mut self, max: u32) -> Self {
pub fn max_connections(mut self, max: usize) -> Self {
self.max_connections = max;
self
}
/// Get the maximum number of connections that this pool should maintain
pub fn get_max_connections(&self) -> u32 {
pub fn get_max_connections(&self) -> usize {
self.max_connections
}
@ -202,13 +202,13 @@ impl<DB: Database> PoolOptions<DB> {
/// [`max_lifetime`]: Self::max_lifetime
/// [`idle_timeout`]: Self::idle_timeout
/// [`max_connections`]: Self::max_connections
pub fn min_connections(mut self, min: u32) -> Self {
pub fn min_connections(mut self, min: usize) -> Self {
self.min_connections = min;
self
}
/// Get the minimum number of connections to maintain at all times.
pub fn get_min_connections(&self) -> u32 {
pub fn get_min_connections(&self) -> usize {
self.min_connections
}