public void initialize ( int [ ] bufferEntrySizes , int [ ] bufferEntryDepths ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) { Tr . entry ( tc , "initialize" ) ; } // order both lists from smallest to largest, based only on Entry Sizes int len = bufferEntrySizes . length ; int [ ] bSizes = new int [ len ] ; int [ ] bDepths = new int [ len ] ; int sizeCompare ; int depth ; int sizeSort ; int j ; for ( int i = 0 ; i < len ; i ++ ) { sizeCompare = bufferEntrySizes [ i ] ; depth = bufferEntryDepths [ i ] ; // go backwards, for speed, since first Array List is // probably already ordered small to large for ( j = i - 1 ; j >= 0 ; j -- ) { sizeSort = bSizes [ j ] ; if ( sizeCompare > sizeSort ) { // add the bigger one after the smaller one bSizes [ j + 1 ] = sizeCompare ; bDepths [ j + 1 ] = depth ; break ; } // move current one down, since it is bigger bSizes [ j + 1 ] = sizeSort ; bDepths [ j + 1 ] = bDepths [ j ] ; } if ( j < 0 ) { // smallest so far, add it at the front of the list bSizes [ 0 ] = sizeCompare ; bDepths [ 0 ] = depth ; } } boolean tracking = trackingBuffers ( ) ; this . pools = new WsByteBufferPool [ len ] ; this . poolsDirect = new WsByteBufferPool [ len ] ; this . poolSizes = new int [ len ] ; for ( int i = 0 ; i < len ; i ++ ) { // make backing pool 10 times larger than local pools this . pools [ i ] = new WsByteBufferPool ( bSizes [ i ] , bDepths [ i ] * 10 , tracking , false ) ; this . poolsDirect [ i ] = new WsByteBufferPool ( bSizes [ i ] , bDepths [ i ] * 10 , tracking , true ) ; this . poolSizes [ i ] = bSizes [ i ] ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Number of pools created: " + this . poolSizes . length ) ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) { Tr . exit ( tc , "initialize" ) ; } }
Initialize the pool manager with the number of pools the entry sizes for each pool and the maximum depth of the free pool .