// $Header: /cvs/gled-1.2/GledCore/Ephra/Mountain.h,v 1.7 2005/03/11 17:50:14 matevz Exp $ // Copyright (C) 1999-2005, Matevz Tadel. All rights reserved. // This file is part of GLED, released under GNU General Public License version 2. // For the licensing terms see $GLEDSYS/LICENSE or http://www.gnu.org/. #ifndef GledCore_Mountain_H #define GledCore_Mountain_H #include #include #include #include #include class Mountain; struct DancerInfo { ZMirEmittingEntity* fOwner; GThread* fThread; Eventor* fEventor; Mountain* fMountain; Operator::Arg* fOpArg; bool fSuspended; bool fSleeping; bool fShouldSuspend; bool fShouldExit; DancerInfo(ZMirEmittingEntity* o, GThread* t, Eventor* e, Mountain* m) : fOwner(o), fThread(t), fEventor(e), fMountain(m), fOpArg(0), fSuspended(false), fSleeping(false), fShouldSuspend(false), fShouldExit(false) {} ~DancerInfo() { delete fThread; } }; #ifndef __CINT__ typedef hash_map hEv2DI_t; typedef hash_map::iterator hEv2DI_i; #endif class Mountain { private: GMutex hStageLock; GCondition hSuspendCond; bool bInSuspend; UInt_t hSuspendCount; protected: #ifndef __CINT__ hEv2DI_t hOnStage; #endif Saturn* mSaturn; // X{g} void stop_thread(DancerInfo* di); public: Mountain(Saturn* s) : hStageLock(GMutex::recursive), mSaturn(s) { bInSuspend = false; } virtual ~Mountain() {} // Eventor request handling void Start(Eventor* e, bool suspend_immediately=false); void Stop(Eventor* e); void Suspend(Eventor* e); void Resume(Eventor* e); void Cancel(Eventor* e); DancerInfo* UnregisterThread(Eventor* e); void WipeThread(Eventor* e); // Suspension mechanism Int_t SuspendAll(); void ResumeAll(); void ConsiderSuspend(DancerInfo* di); // Shutdown ... kill all threads void Shutdown(); static void DancerCooler(DancerInfo* di); static void* DancerBeat(DancerInfo* di); #include "Mountain.h7" ClassDef(Mountain, 0) }; // endclass Mountain #endif