use of concurrent.LockedReachableThreadLocal in project solution-finder by knewjade.
the class PackSearcherComparingParityBasedTest method createUsingBlockAndValidKeyMementoFilter.
// パフェするまでに有効なブロック数を列挙する
private SolutionFilter createUsingBlockAndValidKeyMementoFilter(Field initField, SizedBit sizedBit, Set<PieceCounter> counters) {
HashSet<Long> validBlockCounters = new HashSet<>();
for (PieceCounter counter : counters) {
List<Piece> usingPieces = counter.getBlocks();
for (int size = 1; size <= usingPieces.size(); size++) {
CombinationIterable<Piece> combinationIterable = new CombinationIterable<>(usingPieces, size);
for (List<Piece> pieces : combinationIterable) {
PieceCounter newCounter = new PieceCounter(pieces);
validBlockCounters.add(newCounter.getCounter());
}
}
}
LockedReachableThreadLocal reachableThreadLocal = new LockedReachableThreadLocal(sizedBit.getHeight());
return new UsingBlockAndValidKeySolutionFilter(initField, validBlockCounters, reachableThreadLocal, sizedBit);
}
use of concurrent.LockedReachableThreadLocal in project solution-finder by knewjade.
the class PercentCoreTest method assertPercentCore.
private void assertPercentCore(Obj obj, double successPercent) throws Exception {
PatternGenerator generator = new LoadedPatternGenerator(obj.patterns);
NormalEnumeratePieces enumeratePieces = new NormalEnumeratePieces(generator, obj.maxDepth, obj.isUsingHold);
Set<LongPieces> blocks = enumeratePieces.enumerate();
Injector injector = Guice.createInjector(new BasicModule(obj.maxClearLine));
Optional<ExecutorService> executorService = obj.isSingleThread ? Optional.empty() : Optional.of(injector.getInstance(ExecutorService.class));
LockedCandidateThreadLocal candidateThreadLocal = injector.getInstance(LockedCandidateThreadLocal.class);
LockedReachableThreadLocal reachableThreadLocal = injector.getInstance(LockedReachableThreadLocal.class);
MinoFactory minoFactory = injector.getInstance(MinoFactory.class);
PercentCore percentCore = getPercentCore(obj, executorService.orElse(null), candidateThreadLocal, reachableThreadLocal, minoFactory);
Field field = FieldFactory.createField(obj.marks);
percentCore.run(field, blocks, obj.maxClearLine, obj.maxDepth);
executorService.ifPresent(ExecutorService::shutdown);
assertThat(percentCore.getResultTree().getSuccessPercent()).isEqualTo(successPercent);
}
Aggregations