@ -142,23 +142,24 @@ public class PackWriter implements AutoCloseable {
private static final Map < WeakReference < PackWriter > , Boolean > instances =
private static final Map < WeakReference < PackWriter > , Boolean > instances =
new ConcurrentHashMap < > ( ) ;
new ConcurrentHashMap < > ( ) ;
private static final Iterable < PackWriter > instancesIterable = new Iterable < PackWriter > ( ) {
private static final Iterable < PackWriter > instancesIterable = ( ) - > new Iterator < PackWriter > ( ) {
@Override
public Iterator < PackWriter > iterator ( ) {
private final Iterator < WeakReference < PackWriter > > it = instances
return new Iterator < PackWriter > ( ) {
. keySet ( ) . iterator ( ) ;
private final Iterator < WeakReference < PackWriter > > it =
instances . keySet ( ) . iterator ( ) ;
private PackWriter next ;
private PackWriter next ;
@Override
@Override
public boolean hasNext ( ) {
public boolean hasNext ( ) {
if ( next ! = null )
if ( next ! = null ) {
return true ;
return true ;
}
while ( it . hasNext ( ) ) {
while ( it . hasNext ( ) ) {
WeakReference < PackWriter > ref = it . next ( ) ;
WeakReference < PackWriter > ref = it . next ( ) ;
next = ref . get ( ) ;
next = ref . get ( ) ;
if ( next ! = null )
if ( next ! = null ) {
return true ;
return true ;
}
it . remove ( ) ;
it . remove ( ) ;
}
}
return false ;
return false ;
@ -179,8 +180,6 @@ public class PackWriter implements AutoCloseable {
throw new UnsupportedOperationException ( ) ;
throw new UnsupportedOperationException ( ) ;
}
}
} ;
} ;
}
} ;
/ * *
/ * *
* Get all allocated , non - released PackWriters instances .
* Get all allocated , non - released PackWriters instances .