File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -169,6 +169,10 @@ void close(){
169
169
clear ();
170
170
}
171
171
172
+ public void cleanup ( DBPort p ){
173
+ p .close ();
174
+ }
175
+
172
176
public boolean ok ( DBPort t ){
173
177
return _addr .equals ( t ._addr );
174
178
}
Original file line number Diff line number Diff line change @@ -65,6 +65,11 @@ public boolean ok( T t ){
65
65
return true ;
66
66
}
67
67
68
+ /**
69
+ * override this if you need to do any cleanup
70
+ */
71
+ public void cleanup ( T t ){}
72
+
68
73
/**
69
74
* @return >= 0 the one to use, -1 don't use any
70
75
*/
@@ -107,6 +112,9 @@ void done( T t , boolean ok ){
107
112
_waiting .release ();
108
113
}
109
114
}
115
+ else {
116
+ cleanup ( t );
117
+ }
110
118
}
111
119
}
112
120
@@ -223,10 +231,14 @@ private void _wherePrint(){
223
231
224
232
/** Clears the pool of all objects. */
225
233
protected void clear (){
226
- _avail .clear ();
227
- _all .clear ();
228
- synchronized ( _where ){
229
- _where .clear (); // is this correct
234
+ synchronized ( _avail ){
235
+ for ( T t : _avail )
236
+ cleanup ( t );
237
+ _avail .clear ();
238
+ _all .clear ();
239
+ synchronized ( _where ){
240
+ _where .clear (); // is this correct
241
+ }
230
242
}
231
243
}
232
244
You can’t perform that action at this time.
0 commit comments