struct InnerPool {
connections: Mutex<Vec<Connection>>,
semaphore: Arc<Semaphore>,
write_mutex: Arc<Mutex<()>>,
}
Expand description
Inner connection pool.
Fields§
§connections: Mutex<Vec<Connection>>
Available connections.
semaphore: Arc<Semaphore>
Counts the number of available connections.
write_mutex: Arc<Mutex<()>>
Write mutex.
This mutex ensures there is at most
one write connection with query_only=0
.
This mutex is locked when write connection is outside the pool.
Implementations§
source§impl InnerPool
impl InnerPool
sourcefn put(&self, connection: Connection)
fn put(&self, connection: Connection)
Puts a connection into the pool.
The connection could be new or returned back.
sourcepub async fn get(self: Arc<Self>, query_only: bool) -> Result<PooledConnection>
pub async fn get(self: Arc<Self>, query_only: bool) -> Result<PooledConnection>
Retrieves a connection from the pool.
Sets query_only
pragma to the provided value
to prevent accidental misuse of connection
for writing when reading is intended.
Only pass query_only=false
if you want
to use the connection for writing.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for InnerPool
impl !RefUnwindSafe for InnerPool
impl Send for InnerPool
impl Sync for InnerPool
impl Unpin for InnerPool
impl !UnwindSafe for InnerPool
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more