use of mcjty.rftoolscontrol.logic.running.RunningProgram in project RFToolsControl by McJty.
the class ProcessorTileEntity method runOrDropEvent.
private void runOrDropEvent(int cardIndex, CompiledEvent event, @Nullable String ticket, @Nullable Parameter parameter) {
if (event.isSingle() && runningEvents.contains(Pair.of(cardIndex, event.getIndex()))) {
// Already running and single
return;
}
CpuCore core = findAvailableCore(cardIndex);
if (core == null) {
// in the queue. If so we drop it. Otherwise we add it
for (QueuedEvent q : eventQueue) {
if (q.getCardIndex() == cardIndex) {
if (q.getCompiledEvent().equals(event)) {
// This event is already in the queue. Just drop it
return;
}
}
}
// We could not find this event in the queue. Schedule it
queueEvent(cardIndex, event, ticket, parameter);
} else {
RunningProgram program = new RunningProgram(cardIndex);
program.startFromEvent(event);
program.setCraftTicket(ticket);
program.setLastValue(parameter);
core.startProgram(program);
if (event.isSingle()) {
runningEvents.add(Pair.of(cardIndex, event.getIndex()));
}
}
}
Aggregations