Skip to content

Commit

Permalink
Malfunctioning status at the end of 23/10, squash this when merging
Browse files Browse the repository at this point in the history
  • Loading branch information
Paolo Fittipaldi authored and Paolo Fittipaldi committed Oct 23, 2024
1 parent 056e8aa commit 351d33d
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 3 deletions.
4 changes: 4 additions & 0 deletions quisp/messages/connection_setup_messages.msg
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ packet ConnectionSetupResponse extends Header
int application_type;
int stack_of_QNodeIndexes[];
}

packet InternalTerminatedRulesetIdsNotifier extends Header {
unsigned long terminated_rulesets_ids[] @appender(appendTerminatedRulesetId);
}
4 changes: 4 additions & 0 deletions quisp/modules/Common/Router.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ void Router::handleMessage(cMessage *msg) {
} else if (dest_addr == my_address && dynamic_cast<OspfPacket *>(msg)) {
send(pk, "rdPort$o");
return;
} else if (dest_addr == my_address && dynamic_cast<InternalTerminatedRulesetIdsNotifier *>(msg)){
bubble("Terminated rulesets IDs list received");
send(pk, "cmPort$o");
return;
}

// RoutingDaemon sends hello packet without desination specified
Expand Down
5 changes: 5 additions & 0 deletions quisp/modules/QRSA/ConnectionManager/ConnectionManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ void ConnectionManager::handleMessage(cMessage *msg) {
delete msg;
return;
}

if (auto *pk = dynamic_cast<InternalTerminatedRulesetIdsNotifier *>(msg)) {
delete msg;
return;
}
}

PurType ConnectionManager::parsePurType(const std::string &pur_type) {
Expand Down
15 changes: 14 additions & 1 deletion quisp/modules/QRSA/RuleEngine/RuleEngine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,11 @@ void RuleEngine::ResourceAllocation(int qnic_type, int qnic_index) {
}
}

void RuleEngine::executeAllRuleSets() { runtimes.exec(); }
void RuleEngine::executeAllRuleSets() {
runtimes.exec();
const auto& terminated_rulesets_ids = runtimes.getTerminatedRulesetIds();
sendTerminatedRulesetIds(terminated_rulesets_ids);
}

void RuleEngine::freeConsumedResource(int qnic_index /*Not the address!!!*/, IStationaryQubit *qubit, QNIC_type qnic_type) {
auto *qubit_record = qnic_store->getQubitRecord(qnic_type, qnic_index, qubit->par("stationary_qubit_address"));
Expand All @@ -383,4 +387,13 @@ void RuleEngine::freeConsumedResource(int qnic_index /*Not the address!!!*/, ISt
bell_pair_store.eraseQubit(qubit_record);
}

void RuleEngine::sendTerminatedRulesetIds(const std::vector<unsigned long>& terminated_rulesets_ids) {
InternalTerminatedRulesetIdsNotifier* pkt = new InternalTerminatedRulesetIdsNotifier();
pkt->setSrcAddr(parentAddress);
pkt->setDestAddr(parentAddress);
for (auto id : terminated_rulesets_ids) {
pkt->appendTerminatedRulesetId(id);
}
send(pkt,"RouterPort$o");
};
} // namespace quisp::modules
1 change: 1 addition & 0 deletions quisp/modules/QRSA/RuleEngine/RuleEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class RuleEngine : public IRuleEngine, public Logger::LoggerBase {
void schedulePhotonEmission(QNIC_type qnic_type, int qnic_index, messages::BSMTimingNotification *notification);
void scheduleMSMPhotonEmission(QNIC_type qnic_type, int qnic_index, messages::EPPSTimingNotification *notification);
void handleStopEmitting(messages::StopEmitting *stop_emit);
void sendTerminatedRulesetIds(const std::vector<unsigned long>& terminated_rulesets_ids);

utils::ComponentProvider provider;
std::unique_ptr<IQNicStore> qnic_store = nullptr;
Expand Down
4 changes: 3 additions & 1 deletion quisp/runtime/RuntimeManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ Runtime *RuntimeManager::findById(unsigned long long ruleset_id) {
}

void RuntimeManager::exec() {
terminated_rulesets.clear();
for (auto it = runtimes.begin(); it != runtimes.end();) {
it->exec();
if (it->terminated) {
terminated_rulesets.push_back(it->ruleset.id);
it = runtimes.erase(it);
} else {
++it;
Expand All @@ -31,5 +33,5 @@ std::vector<Runtime>::iterator RuntimeManager::begin() { return runtimes.begin()
std::vector<Runtime>::iterator RuntimeManager::end() { return runtimes.end(); }
std::vector<Runtime>::reference RuntimeManager::at(size_t index) { return runtimes.at(index); }
size_t RuntimeManager::size() const { return runtimes.size(); }

const std::vector<unsigned long>& RuntimeManager::getTerminatedRulesetIds() const {return terminated_rulesets; }
} // namespace quisp::runtime
3 changes: 2 additions & 1 deletion quisp/runtime/RuntimeManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ class RuntimeManager {
std::vector<Runtime>::iterator end();
std::vector<Runtime>::reference at(size_t);
size_t size() const;

const std::vector<unsigned long>& getTerminatedRulesetIds() const;
protected:
std::vector<Runtime> runtimes = {};
std::unique_ptr<Runtime::ICallBack> callback;
std::vector<unsigned long> terminated_rulesets;
};
} // namespace quisp::runtime

0 comments on commit 351d33d

Please sign in to comment.