mirror of
https://gitlab.com/manzerbredes/loosely-coupled-dss-extended.git
synced 2025-04-05 19:16:26 +02:00
Cleaning code
This commit is contained in:
parent
659ad990e8
commit
410667ce90
1 changed files with 9 additions and 11 deletions
|
@ -68,9 +68,9 @@ public:
|
|||
double hint; // The timestamp that should be used by the receiver
|
||||
double duration; // The duration that should be used by the receiver
|
||||
bool HasHint;
|
||||
bool HasData;
|
||||
bool HasData; // This way observer could check if they want to receive data (maybe they already received data)
|
||||
bool HisForward;
|
||||
bool Abort;
|
||||
bool Abort; // Allow the receiver to abort a communication (if they already received the data for example) and unlock the sender
|
||||
u32 DataSize;
|
||||
std::string DedicatedMailbox; // Dedicated mailbox used by the sender/receiver
|
||||
};
|
||||
|
@ -78,7 +78,6 @@ public:
|
|||
/// @brief Observation node code
|
||||
static void obs_node(std::vector<std::string> args);
|
||||
|
||||
|
||||
/**
|
||||
* No arguments are require (cf inputs.json)
|
||||
*/
|
||||
|
@ -98,7 +97,7 @@ int main(int argc, char **argv) {
|
|||
// Init all nodes actors
|
||||
u32 nON=simgrid::s4u::Engine::get_instance()->get_host_count();
|
||||
for(u32 i=0;i<nON;i++){
|
||||
std::vector<std::string> args;
|
||||
std::vector<std::string> args; // No args
|
||||
std::ostringstream ss;
|
||||
ss<< "on" <<i;
|
||||
simgrid::s4u::Actor::create("ON", simgrid::s4u::Host::by_name(ss.str()), obs_node, args);
|
||||
|
@ -118,7 +117,7 @@ static void obs_node(std::vector<std::string> args) {
|
|||
// Init various variables
|
||||
std::string selfName = simgrid::s4u::this_actor::get_host()->get_name();
|
||||
simgrid::s4u::this_actor::get_host()->turn_on();
|
||||
Inputs i(selfName);
|
||||
Inputs i(selfName); // Load node input parameters from the json file
|
||||
simgrid::s4u::Mailbox *m = simgrid::s4u::Mailbox::by_name("medium");
|
||||
XBT_INFO("Deploying observation node %s",CNAME);
|
||||
|
||||
|
@ -167,10 +166,7 @@ static void obs_node(std::vector<std::string> args) {
|
|||
SEND(m_ded->put(p,p->DataSize,uptime)); // Send the actual hint
|
||||
XBT_INFO("%s sent a hint successfully",CNAME);
|
||||
}
|
||||
catch(...){
|
||||
|
||||
}
|
||||
|
||||
catch(...){}
|
||||
}
|
||||
// Send data if send hint mode is disable
|
||||
else{
|
||||
|
@ -245,9 +241,10 @@ static void obs_node(std::vector<std::string> args) {
|
|||
}
|
||||
} while(p->HisForward);
|
||||
simgrid::s4u::Mailbox *m_ded= simgrid::s4u::Mailbox::by_name(p->DedicatedMailbox);
|
||||
// Inform the sender that we do not want to abort
|
||||
Payload *ack=new Payload();
|
||||
ack->Abort=false;
|
||||
m_ded->put(ack,0);
|
||||
m_ded->put(ack,0); // Instantaneous msg
|
||||
// Start receiving data
|
||||
MODE_RX();
|
||||
if(p->HasHint && !p->HasData){
|
||||
|
@ -288,6 +285,7 @@ static void obs_node(std::vector<std::string> args) {
|
|||
else {
|
||||
XBT_INFO("%s is observing his environment...",CNAME);
|
||||
MODE_ON();
|
||||
// If use hint we should listen for the sender
|
||||
if(i.use_hint){
|
||||
if((forward_mode|forward_only) && hint_forward!=NULL && CLOCK < hint_forward->hint){
|
||||
FORWARD_HINT(FOR(1));
|
||||
|
@ -332,7 +330,7 @@ static void obs_node(std::vector<std::string> args) {
|
|||
// Load next event
|
||||
i.GotoNextEvent();
|
||||
nWakeUp++; // Increase the number of wake up
|
||||
totalUptime+=CLOCK-upsince;
|
||||
totalUptime+=CLOCK-upsince; // Synchronize total uptime
|
||||
}
|
||||
// Done
|
||||
MODE_OFF()
|
||||
|
|
Loading…
Add table
Reference in a new issue