/** * Apply the given work to the material in a thread-safe way, possibly by * combining it with other work. * * @param work The work to be done. * @throws ExecutionException if this thread ends up performing the piled up work, * and any work unit in the pile throws an exception. Thus the current thread is not * guaranteed to observe any exception its unit of work might throw, since the * exception will be thrown in whichever thread that ends up actually performing the work. */ public void apply( W work ) throws ExecutionException { // Schedule our work on the stack. WorkUnit<Material,W> unit = enqueueWork( work ); // Try grabbing the lock to do all the work, until our work unit // has been completed. int tryCount = 0; do { tryCount++; checkFailure( tryDoWork( unit, tryCount, true ) ); } while ( !unit.isDone() ); }
@Override public void await() throws ExecutionException { checkFailure( throwable ); int tryCount = 0; while ( !unit.isDone() ) { tryCount++; checkFailure( throwable = tryDoWork( unit, tryCount, true ) ); } } };
/** * Apply the given work to the material in a thread-safe way, possibly by * combining it with other work. * * @param work The work to be done. * @throws ExecutionException if this thread ends up performing the piled up work, * and any work unit in the pile throws an exception. Thus the current thread is not * guaranteed to observe any exception its unit of work might throw, since the * exception will be thrown in whichever thread that ends up actually performing the work. */ public void apply( W work ) throws ExecutionException { // Schedule our work on the stack. WorkUnit<Material,W> unit = enqueueWork( work ); // Try grabbing the lock to do all the work, until our work unit // has been completed. int tryCount = 0; do { tryCount++; checkFailure( tryDoWork( unit, tryCount, true ) ); } while ( !unit.isDone() ); }
@Override public void await() throws ExecutionException { checkFailure( throwable ); int tryCount = 0; while ( !unit.isDone() ) { tryCount++; checkFailure( throwable = tryDoWork( unit, tryCount, true ) ); } } };