Search in sources :

Example 1 with LockedCandidateThreadLocal

use of concurrent.LockedCandidateThreadLocal 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);
}
Also used : PatternGenerator(common.pattern.PatternGenerator) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) BasicModule(module.BasicModule) LoadedPatternGenerator(common.pattern.LoadedPatternGenerator) LockedReachableThreadLocal(concurrent.LockedReachableThreadLocal) Field(core.field.Field) LongPieces(common.datastore.blocks.LongPieces) Injector(com.google.inject.Injector) LockedCandidateThreadLocal(concurrent.LockedCandidateThreadLocal) NormalEnumeratePieces(entry.searching_pieces.NormalEnumeratePieces) ExecutorService(java.util.concurrent.ExecutorService) MinoFactory(core.mino.MinoFactory)

Aggregations

Injector (com.google.inject.Injector)1 LongPieces (common.datastore.blocks.LongPieces)1 LoadedPatternGenerator (common.pattern.LoadedPatternGenerator)1 PatternGenerator (common.pattern.PatternGenerator)1 LockedCandidateThreadLocal (concurrent.LockedCandidateThreadLocal)1 LockedReachableThreadLocal (concurrent.LockedReachableThreadLocal)1 Field (core.field.Field)1 MinoFactory (core.mino.MinoFactory)1 NormalEnumeratePieces (entry.searching_pieces.NormalEnumeratePieces)1 ExecutorService (java.util.concurrent.ExecutorService)1 BasicModule (module.BasicModule)1