![]() |
User Manual, Developers Guide and API Documentation |
![]() |
00001 /******************************************************************************* 00002 * This file is part of openWNS (open Wireless Network Simulator) 00003 * _____________________________________________________________________________ 00004 * 00005 * Copyright (C) 2004-2007 00006 * Chair of Communication Networks (ComNets) 00007 * Kopernikusstr. 16, D-52074 Aachen, Germany 00008 * phone: ++49-241-80-27910, 00009 * fax: ++49-241-80-22242 00010 * email: info@openwns.org 00011 * www: http://www.openwns.org 00012 * _____________________________________________________________________________ 00013 * 00014 * openWNS is free software; you can redistribute it and/or modify it under the 00015 * terms of the GNU Lesser General Public License version 2 as published by the 00016 * Free Software Foundation; 00017 * 00018 * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY 00019 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 00020 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00021 * details. 00022 * 00023 * You should have received a copy of the GNU Lesser General Public License 00024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00025 * 00026 ******************************************************************************/ 00027 00028 #ifndef WNS_EVENTS_PERIODICREALTIMEOUT_HPP 00029 #define WNS_EVENTS_PERIODICREALTIMEOUT_HPP 00030 00031 #include <WNS/events/scheduler/ICommand.hpp> 00032 00033 #include <pthread.h> 00034 00035 namespace wns { namespace events { 00036 00047 class PeriodicRealTimeout 00048 { 00052 class PeriodicRealTimeoutCommand 00053 { 00054 public: 00055 explicit 00056 PeriodicRealTimeoutCommand(PeriodicRealTimeout* _dest) : 00057 dest(_dest) 00058 {} 00059 00060 void 00061 operator()() 00062 { 00063 dest->periodically(); 00064 } 00065 00066 private: 00067 PeriodicRealTimeout* dest; 00068 }; // PeriodicRealTimeoutCommand 00069 00070 public: 00071 explicit 00072 PeriodicRealTimeout(); 00073 00074 virtual 00075 ~PeriodicRealTimeout(); 00076 00088 void 00089 startPeriodicTimeout(double _period, double _delay = 0.0); 00090 00095 bool 00096 hasPeriodicRealTimeoutSet(); 00097 00104 void 00105 cancelPeriodicRealTimeout(); 00106 00113 virtual void 00114 periodically() = 0; 00115 00116 private: 00117 pthread_cond_t dataRead; 00118 pthread_mutex_t mutex; 00119 double period; 00120 double delay; 00121 00122 00123 bool running; 00124 pthread_t thread; 00125 wns::events::scheduler::ICommandPtr currentCommand; 00126 00127 static void* worker(void* _arg); 00128 }; // PeriodicRealTimeOut 00129 00130 } // events 00131 } // wns 00132 00133 00134 #endif // NOT defined WNS_EVENTS_PERIODICREALTIMEOUT_HPP 00135 00136
1.5.5