[Ns-developers] ns-3 and future development
Mathieu Lacage
Mathieu.Lacage at sophia.inria.fr
Tue Jan 17 08:14:24 PST 2006
On Mon, 2006-01-16 at 22:08 -0800, Tom Henderson wrote:
> > Is the following not simple enough ?
> > Simulation::insert_at_s (10.0, make_event (&MyClass::timeout, my_class,
> > context));
>
> Ability to schedule, reschedule, cancel, and inquire about the status of
> the timer. Might require the above method returning a handle to the
> event, and some "status_" flag in the event that can be used to
> deactivate it without having to traverse the data structure to find the
> event-- this stuff has been worked out before in other simulators.
I did spend a bit of time thinking more about this API. Would you be
okay with something like this:
event-cancellable.h:
class EventCancellable: public Event {
public:
EventCancellable ()
: m_state (INITIAL) {}
bool is_canceled (void) {
return (m_state == CANCEL)?true:false;
}
void cancel (void) {
assert (m_state == INITIAL);
m_state = CANCEL;
}
private
typedef {
INITIAL = 0,
CANCEL = 1,
DEAD = 2
};
virtual void notify (void) {
assert (m_state != DEAD);
if (!m_canceled) {
do_notify ();
}
delete this;
}
~EventCancellable () {
m_state = DEAD;
}
virtual void do_notify (void) = 0;
uint8_t m_state : 2;
};
and event-cancellable.tcc which defines a bunch of
make_cancellable_event () functions
This API is maybe a bit too simplistic. What do you think ?
Mathieu
--
More information about the Ns-developers
mailing list