[ROOT] time ...

From: Stefano Argiro' (argiro@to.infn.it)
Date: Thu Dec 06 2001 - 14:47:20 MET


hi, 

could somebody explain to the ignorants (myself)
why the interpreted class timer (as in timer3.C below) does what I want
(prints "Timeout ! "
every 1 sec),
while the compiled class timer (as in timer2.C) does not ? (root v3.0)




Thanks
			Stefano



----------------------------------------------------------
Stefano Argiro', Ph.D.
University of Turin, Experimental Physics Department
and INFN
via P. Giuria 1
10125 Torino
Italy

tel +39-011-670-7334
fax +39-011-669-1104





File timer3.C
-----------------------------------------------------------------
// interpret it ! .
// .L timer3.C
// timer * t = new timer;
// prints "Timeout !" every second

class timer {
	private:
	
	TTimer *ftim; 

	public:
	
	timer (){
	
		ftim = new TTimer(1000);
		ftim->Connect("Timeout","timer", this, "TimeOut()");
		
//		gSystem->AddTimer(ftim);
//		ftim->TurnOn();
		ftim->Start();
	}
		
	void TimeOut(){cout << "Timeout !"<<endl;}	

};

------------------------------------------------------------------------
File timer2.C
------------------------------------------------------------------------


#include "TTimer.h"
#include "TROOT.h"
#include "TApplication.h"
#include "TSystem.h"
#include <iostream.h>


/* Compile with 

gcc -I $ROOTSYS/include  -L$ROOTSYS/lib -lCore \
 -lCint -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript \
 -lMatrix -lPhysics -lm -ldl -lpthread -rdynamic -lm -ldl -rdynamic
-lThread\
 -o prova timer2.C

does nothing !

*/

class timer {
	private:
	
	TTimer *ftim; 

	public:
	
	timer (){
	
		ftim = new TTimer(1000);
		ftim->Connect("Timeout","timer", this, "TimeOut()");
		
//		gSystem->AddTimer(ftim);
//		ftim->TurnOn();
		ftim->Start();
	}
		
	void TimeOut(){cout << "Timeout !"<<endl;}	

};



int main (int argc, char ** argv ){
		
		TROOT  r("p","q");
		TApplication *app = new TApplication("App", &argc, argv,NULL,0);
		
		cout << "creating and starting timer" <<endl;
		
		timer *t = new timer;
		
	    	gSystem->ProcessEvents();
		
		app->Run();
		
		
//		while (1);

return 1;
}



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:11 MET