private Throwable doSynchronizedWork( WorkUnit<Material,W> batch ) { W combinedWork = combine( batch ); Throwable failure = null; if ( combinedWork != null ) { try { combinedWork.apply( material ); } catch ( Throwable throwable ) { failure = throwable; } } return failure; }
private W combine( WorkUnit<Material,W> batch ) { W result = null; while ( batch != stackEnd ) { if ( result == null ) { result = batch.work; } else { result = result.combine( batch.work ); } WorkUnit<Material,W> tmp = batch.next; while ( tmp == null ) { // We may see 'null' via race, as work units are put on the // stack before their 'next' pointers are updated. We just spin // until we observe their volatile write to 'next'. // todo Java9: Thread.onSpinWait() ? Thread.yield(); tmp = batch.next; } batch = tmp; } return result; }
private Throwable doSynchronizedWork( WorkUnit<Material,W> batch ) { W combinedWork = combine( batch ); Throwable failure = null; if ( combinedWork != null ) { try { combinedWork.apply( material ); } catch ( Throwable throwable ) { failure = throwable; } } return failure; }
private W combine( WorkUnit<Material,W> batch ) { W result = null; while ( batch != stackEnd ) { if ( result == null ) { result = batch.work; } else { result = result.combine( batch.work ); } WorkUnit<Material,W> tmp = batch.next; while ( tmp == null ) { // We may see 'null' via race, as work units are put on the // stack before their 'next' pointers are updated. We just spin // until we observe their volatile write to 'next'. // todo Java9: Thread.onSpinWait() ? Thread.yield(); tmp = batch.next; } batch = tmp; } return result; }