SchedulerPC.cxx
Go to the documentation of this file.00001 /* ======================================================================== 00002 * Copyright (C) 2005 Graz University of Technology 00003 * 00004 * This framework is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This framework is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this framework; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * For further information please contact Dieter Schmalstieg under 00019 * <schmalstieg@icg.tu-graz.ac.at> or write to Dieter Schmalstieg, 00020 * Graz University of Technology, Inffeldgasse 16a, A8010 Graz, 00021 * Austria. 00022 * ======================================================================== 00023 * PROJECT: OpenVideo 00024 * ======================================================================== */ 00031 /* ======================================================================= */ 00032 00033 #include <openvideo/SchedulerPC.h> 00034 #include <openvideo/TimerACE.h> 00035 #include <openvideo/Manager.h> 00036 #include <ace/Thread_Mutex.h> 00037 #include <ace/Condition_Thread_Mutex.h> 00038 00039 using namespace openvideo; 00040 00041 00042 SchedulerPC::SchedulerPC() 00043 { 00044 exitIdle=false; 00045 } 00046 00047 SchedulerPC::~SchedulerPC() 00048 { 00049 if(timer) 00050 delete timer; 00051 if(updateLock) 00052 delete updateLock; 00053 if(updateLockCond) 00054 delete updateLockCond; 00055 } 00056 00057 void 00058 SchedulerPC::scheduleIdle() 00059 { 00060 while(!exitIdle) 00061 { 00062 Manager::update(NULL); 00063 } 00064 } 00065 void 00066 SchedulerPC::scheduleTimer() 00067 { 00068 timer=new TimerACE(); 00069 timer->schedule(Manager::update, 00070 NULL, 00071 double(1.0/(double)updateRate)); 00072 00073 Manager::getInstance()->getLogger()->log("\nOpenVideo: start main loop !\n"); 00074 timer->runEventLoop(); 00075 } 00076 00077 void 00078 SchedulerPC::schedulePoll() 00079 { 00080 updateLock=new ACE_Thread_Mutex(); 00081 updateLockCond=new ACE_Condition_Thread_Mutex(*updateLock); 00082 updateLockCond->wait(); 00083 } 00084 00085 void 00086 SchedulerPC::unscheduleIdle() 00087 { 00088 exitIdle=true; 00089 } 00090 00091 void 00092 SchedulerPC::unscheduleTimer() 00093 { 00094 if(timer) 00095 delete timer; 00096 } 00097 00098 void 00099 SchedulerPC::unschedulePoll() 00100 { 00101 updateLockCond->broadcast(); 00102 if(updateLock) 00103 delete updateLock; 00104 if(updateLockCond) 00105 delete updateLockCond; 00106 } 00107 00108 00109 00110 //======================================================================== 00111 // End of SchedulerPC.cxx 00112 //======================================================================== 00113 // Local Variables: 00114 // mode: c++ 00115 // c-basic-offset: 4 00116 // eval: (c-set-offset 'substatement-open 0) 00117 // eval: (c-set-offset 'case-label '+) 00118 // eval: (c-set-offset 'statement 'c-lineup-runin-statements) 00119 // eval: (setq indent-tabs-mode nil) 00120 // End: 00121 //========================================================================
