Hi, i use a stack of File/Dir pairs ... like in: struct FD_pair { TFile* file; TDirectory* dir; FD_pair(TFile* f, TDirectory* d) : file(f), dir(d) {} }; stack<FD_pair> FDstack; GMutex FDmutex(GMutex::recursive); void GledNS::PushFD() { FDmutex.Lock(); FDstack.push(FD_pair(gFile, gDirectory)); } void GledNS::PopFD() { gFile = FDstack.top().file; FDstack.top().dir->cd(); FDstack.pop(); FDmutex.Unlock(); } Those are put in a namespace ... the FDmutex is needed as lots of ROOT's functions operate on current dir/file and this seemed the cheapest way around it in my implementation of threads. Since the topic is opened ... how about putting all the ROOT's globals in a separate namespace/class with access methods for global objects. In short ... somewhere where they can be overridden. This would make implementation of threads much simpler. (eg. returning the gFile based on value of thread_self) Disclaimer: I only checked the TThread implementation in its early phase of development ... and than reinvented the wheel myself. So perhaps i'm talking nonsense. Cheers, matevz On Sat, 24 Feb 2001, Anton Fokin wrote: > Hi Rene and rooters, > > I think it would be convinient if you add > StoreCurrenttFileDir()/RestoreCurrentFileDir() (global?) functions since > they are used in near any operation with TFile->cd(). > > Regards, > Anton > > http://www.smartquant.com > > > -- --------------------------------------------------- Matevz Tadel, E-mail: Matevz.Tadel@ijs.si Department of Experimental High Energy Physics F9 Jozef Stefan Institute, Jamova 39, P.o.Box 3000 SI-1001 Ljubljana, Slovenia Tel.: +386-1-477-3674 Fax: +386-1-425-7074 ---------------------------------------------------
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:37 MET