@ Override public int size ( ) { stateLock . readLock ( ) . lock ( ) ; try { switch ( state ) { default : // This list might be empty or full or somewhere in between: // we don't know until we look! preFetchAll ( ) ; // The list is now either complete or timed out - recurse to find the result. return size ( ) ; case TIMED_OUT : return currentSize ( ) ; case COMPLETE_WITH_FAILURES : return elements . length - failedKeys . size ( ) ; case COMPLETE : return elements . length ; } } finally { stateLock . readLock ( ) . unlock ( ) ; } }
Find the size of this list attempting to retrieve all elements if necessary .