How to avoid using send()/sendDelayed() function in multiple places at the same time?

14 views
Skip to first unread message

Alexander Wang

unread,
Jun 12, 2018, 11:50:56 PM6/12/18
to OMNeT++ Users
Hello:
     Is there a function that can detect if a module is currently using the send()/sendDelayed() function? I just want to avoid the following questions:

Thanks very much! 

Alfonso Ariza Quintana

unread,
Jun 13, 2018, 3:48:56 AM6/13/18
to omn...@googlegroups.com

You can check if the packet is scheduled already

 

if (!pkt->isScheduled())

--
You received this message because you are subscribed to the Google Groups "OMNeT++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+u...@googlegroups.com.
Visit this group at https://groups.google.com/group/omnetpp.
For more options, visit https://groups.google.com/d/optout.

荣巍

unread,
Jun 13, 2018, 4:44:10 AM6/13/18
to omn...@googlegroups.com
Hello, Alfonso:
      Thanks for your replay! I am also intend to use this way, but if I check by xxx->isScheduled() in other module, but I do not know the xxx'name in this module.

Alfonso Ariza Quintana <aari...@hotmail.com> 于2018年6月13日周三 下午3:48写道:
You received this message because you are subscribed to a topic in the Google Groups "OMNeT++ Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/omnetpp/YkwncjKefxc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to omnetpp+u...@googlegroups.com.

Alfonso Ariza Quintana

unread,
Jun 13, 2018, 5:47:34 AM6/13/18
to omn...@googlegroups.com

It is the packet

if (!pkt->isScheduled())  send(pkt,”out”);

 

But if you have this error is that you have something strange in the code, in the moment that a module sends a packer the module must ignore/delete the references to the packet, for example

send(pkt,”out”);

pkt = nullptr;

For efficiency, the simulators send the packet instead of a copy of the packet.

荣巍

unread,
Jun 14, 2018, 7:09:39 AM6/14/18
to omn...@googlegroups.com
Alfonso, Thank you very much! I make a stupid mistake just like below:

for(xx;xx;xx){
    send(xx);
}




Alfonso Ariza Quintana <aari...@hotmail.com> 于2018年6月13日周三 下午5:47写道:
Reply all
Reply to author
Forward
0 new messages