[Click] Timer, the 2nd

el.drago@tiscali.it el.drago at tiscali.it
Tue Jul 24 04:20:21 EDT 2007


Hi Beyers, first of all thanks for your answer. 
I tried to modify as you wrote, the warning easly went away, the code 
run, but the function "Element::run_timer()" called only once doesn't 
re-call itself after the msec set in its code.
Basically I want that I call run_timer() once and if I don't reset the 
timer [ps: HOW?!] later in the main code it will start the countdown 
and when finished, do the stuff in it and re-start itself.
Where I wrong?
I post my code [well, only the essential] so you or anyone who could 
advice me can do it.

Thanks once more for your help!
Max


Elment::Element() : timer(this){
	#if CLICK_USERLEVEL
	_outfile = 0;
	#endif
}

int Element::initialize(ErrorHandler *errh){
	#if CLICK_USERLEVEL
		if (_outfilename) {
			_outfile = fopen(_outfilename.c_str(), "wb");
			if (!_outfile)
			return errh->error("%s: %s", _outfilename.c_str(), strerror
(errno));
		}
	#else
		(void) errh;
	#endif

 	timer.initialize(this);
 	timer.schedule_after_msec(1000);

	return 0;
}

void Element::run_timer(){
	//click_chatter("Hello world, damned timer !");
	timer.schedule_after_msec(1000);
}

void Element::push(int port, Packet *p){
	// ... stuff ...
	// this function is only called once, blah is set = 0 in configure 
(ok, silly way to do it, just for debug now)
	if (blah==0){
		run_timer();
	}
	blah++;
	// ... stuff ...
	return;
}




_______________________________________
Stampa on line i tuoi ricordi con Tiscali.Photo
http://photo.tiscali.it//



More information about the click mailing list