@@ -3,11 +3,11 @@ use std::sync::atomic::{AtomicBool, AtomicU32, Ordering};
3
3
use std:: sync:: Arc ;
4
4
use std:: time:: Instant ;
5
5
6
+ use async_std:: { future:: timeout, task} ;
6
7
use crossbeam_queue:: { ArrayQueue , SegQueue } ;
7
8
use futures_channel:: oneshot:: { channel, Sender } ;
8
- use async_std:: { task, future:: timeout} ;
9
9
10
- use super :: { Idle , Options , Live } ;
10
+ use super :: { Idle , Live , Options } ;
11
11
use crate :: { error:: Error , Connection , Database } ;
12
12
13
13
pub ( super ) struct SharedPool < DB >
27
27
DB : Database ,
28
28
DB :: Connection : Connection < Database = DB > ,
29
29
{
30
- pub ( super ) async fn new_arc (
31
- url : & str ,
32
- options : Options ,
33
- ) -> crate :: Result < Arc < Self > > {
30
+ pub ( super ) async fn new_arc ( url : & str , options : Options ) -> crate :: Result < Arc < Self > > {
34
31
let pool = Arc :: new ( Self {
35
32
url : url. to_owned ( ) ,
36
33
idle : ArrayQueue :: new ( options. max_size as usize ) ,
48
45
. eventually_connect ( Instant :: now ( ) + pool. options . connect_timeout )
49
46
. await ?;
50
47
51
- // Ignore error here, we are capping this loop by min_size which we
48
+ // Ignore error here, we are capping this loop by min_size which we
52
49
// already should make sure is less than max_size
53
50
let _ = pool. idle . push ( Idle {
54
51
live,
@@ -114,9 +111,7 @@ where
114
111
// successfully released
115
112
Ok ( ( ) ) => return ,
116
113
117
- Err ( live) => {
118
- live
119
- } ,
114
+ Err ( live) => live,
120
115
} ;
121
116
}
122
117
@@ -143,7 +138,7 @@ where
143
138
}
144
139
145
140
let size = self . size . load ( Ordering :: Acquire ) ;
146
-
141
+
147
142
if size >= self . options . max_size {
148
143
// Too many open connections
149
144
// Wait until one is available
0 commit comments