use of il.ac.bgu.cs.bp.bpjs.execution.tasks.StartBThread in project BPjs by bThink-BGU.
the class BProgramSyncSnapshot method start.
/**
* Starts the BProgram - runs all the registered b-threads to their first
* {@code bsync}.
*
* @param exSvc the executor service that will advance the threads.
* @return A snapshot of the program at the first {@code bsync}.
* @throws java.lang.InterruptedException
*/
public BProgramSyncSnapshot start(ExecutorService exSvc) throws InterruptedException {
Set<BThreadSyncSnapshot> nextRound = new HashSet<>(threadSnapshots.size());
BPEngineTask.Listener halter = new HaltOnAssertion(exSvc);
nextRound.addAll(exSvc.invokeAll(threadSnapshots.stream().map(bt -> new StartBThread(bt, halter)).collect(toList())).stream().map(f -> safeGet(f)).collect(toList()));
// FIXME test for assertion failures
executeAllAddedBThreads(nextRound, exSvc, halter);
List<BEvent> nextExternalEvents = new ArrayList<>(getExternalEvents());
nextExternalEvents.addAll(bprog.drainEnqueuedExternalEvents());
return new BProgramSyncSnapshot(bprog, nextRound, nextExternalEvents, violationRecord.get());
}
Aggregations