MCPcopy Index your code
hub / github.com/FabricMC/Matcher / runInParallel

Method runInParallel

src/main/java/matcher/Matcher.java:542–567  ·  view source on GitHub ↗
(List<T> workSet, Consumer<T> worker, DoubleConsumer progressReceiver)

Source from the content-addressed store, hash-verified

540 }
541
542 public static <T, C> void runInParallel(List<T> workSet, Consumer<T> worker, DoubleConsumer progressReceiver) {
543 if (workSet.isEmpty()) return;
544
545 AtomicInteger itemsDone = new AtomicInteger();
546 int updateRate = Math.max(1, workSet.size() / 200);
547
548 try {
549 List<Future<Void>> futures = threadPool.invokeAll(workSet.stream().<Callable<Void>>map(workItem -> () -> {
550 worker.accept(workItem);
551
552 int cItemsDone = itemsDone.incrementAndGet();
553
554 if ((cItemsDone % updateRate) == 0) {
555 progressReceiver.accept((double) cItemsDone / workSet.size());
556 }
557
558 return null;
559 }).collect(Collectors.toList()));
560
561 for (Future<Void> future : futures) {
562 future.get();
563 }
564 } catch (ExecutionException | InterruptedException e) {
565 throw new RuntimeException(e);
566 }
567 }
568
569 public boolean autoMatchMethods(DoubleConsumer progressReceiver) {
570 return autoMatchMethods(autoMatchLevel, absMethodAutoMatchThreshold, relMethodAutoMatchThreshold, progressReceiver);

Callers 3

autoMatchClassesMethod · 0.95
matchMethod · 0.95
autoMatchMethodVarsMethod · 0.95

Calls 4

sizeMethod · 0.80
mapMethod · 0.80
acceptMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected