4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief Timer public header */
30 #include "Scheduler.hh"
32 //#include "Timer.mpp"
33 ///////////////////////////////hh.p////////////////////////////////////////
37 /** \brief Manage scheduler timer
39 This class will manage a single timer: The timer can be enabled, disabled and updated and
40 will automatically be removed, when this instance is destroyed.
46 Foo() : timer_ ( ClockServer::now() + ClockService::milliseconds(500),
47 senf::membind(&Foo::timer, this) ) {}
49 void blarf() { timer_.disable(); }
54 senf::SchedulerTimer timer_;
62 ///////////////////////////////////////////////////////////////////////////
63 ///\name Structors and default members
66 SchedulerTimer(ClockService::clock_type timeout, Scheduler::SimpleCallback const & cb,
71 ///////////////////////////////////////////////////////////////////////////
73 void enable(); ///< Enable timer
74 void disable(); ///< Disable timer
75 bool enabled(); ///< \c true, if timer is currently enabled
76 /**< An expired timer can still be in enabled state. */
78 void update(ClockService::clock_type timeout); ///< Change timeout time and enable timer
79 /**< If the timer is not enabled, you need to call enable()
80 for the timer to become effective. */
85 ClockService::clock_type timeout_;
86 Scheduler::SimpleCallback cb_;
93 ///////////////////////////////hh.e////////////////////////////////////////
96 //#include "Timer.cti"
103 // comment-column: 40
104 // c-file-style: "senf"
105 // indent-tabs-mode: nil
106 // ispell-local-dictionary: "american"
107 // compile-command: "scons -u test"