[Click] Timer, the 2nd

Eddie Kohler kohler at cs.ucla.edu
Tue Jul 24 16:56:12 EDT 2007


Do not call your Element Element.  That is asking for trouble (if in 
fact you are doing that).

If you are running Click on current Git/CVS code, you should call your 
run_timer() function run_timer(Timer *); but that shouldn't matter.

I think you may have left out something important in your code, because 
this should work.  I have attached a silly element that does what you 
want, and prints a stream of "A"s.

Eddie




el.drago at tiscali.it wrote:
> 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//
> 
> _______________________________________________
> click mailing list
> click at amsterdam.lcs.mit.edu
> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: crapaud.hh
Url: https://pdos.csail.mit.edu/pipermail/click/attachments/20070724/56e16ef7/crapaud-0002.diff
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: crapaud.cc
Url: https://pdos.csail.mit.edu/pipermail/click/attachments/20070724/56e16ef7/crapaud-0003.diff


More information about the click mailing list