private List < BBContainer > getOutputBuffers ( Collection < SnapshotTableTask > tableTasks , boolean noSchedule ) { final int desired = tableTasks . size ( ) ; while ( true ) { int available = m_availableSnapshotBuffers . get ( ) ; //Limit the number of buffers used concurrently if ( desired > available ) { return null ; } if ( m_availableSnapshotBuffers . compareAndSet ( available , available - desired ) ) break ; } List < BBContainer > outputBuffers = new ArrayList < BBContainer > ( tableTasks . size ( ) ) ; for ( int ii = 0 ; ii < tableTasks . size ( ) ; ii ++ ) { final BBContainer origin = DBBPool . allocateDirectAndPool ( m_snapshotBufferLength ) ; outputBuffers . add ( createNewBuffer ( origin , noSchedule ) ) ; } return outputBuffers ; }
Create an output buffer for each task .