4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Jens Moedeker <jens.moedeker@fokus.fraunhofer.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 TimerEventProxy public header */
28 \brief TimerEventProxy.test non-inline non-template implementation */
30 //#include "TimerEventProxy.test.hh"
31 //#include "TimerEventProxy.test.ih"
34 #include "TimerEventProxy.hh"
35 #include "Scheduler.hh"
36 #include <boost/bind.hpp>
38 #include <senf/Utils/auto_unit_test.hh>
39 #include <boost/test/test_tools.hpp>
40 #include <boost/random.hpp>
43 ///////////////////////////////cc.p////////////////////////////////////////
48 void handler( senf::ClockService::clock_type time, int const &id)
50 std::cerr << "TimerEventProxy handler count="<<count<<" id="<<id<<"\n";
55 std::cerr << "TimerEventProxy terminating\n";
56 senf::scheduler::terminate();
61 SENF_AUTO_UNIT_TEST(timerEventProxy)
64 // // abort on watchdog timeout
65 // senf::scheduler::watchdogAbort( true);
66 // senf::scheduler::watchdogTimeout(5000);
68 senf::ClockService::clock_type t (senf::ClockService::now());
70 senf::scheduler::TimerEventProxy<int> timers;
72 SENF_CHECK_NO_THROW( timers.add( t + senf::ClockService::milliseconds(10000), 0 , &handler));
73 SENF_CHECK_NO_THROW( timers.add( t + senf::ClockService::milliseconds(800), 3, &handler));
74 SENF_CHECK_NO_THROW( timers.add( t + senf::ClockService::milliseconds(200), 1, &handler));
75 SENF_CHECK_NO_THROW( timers.del( 3));
76 SENF_CHECK_NO_THROW( timers.add( t + senf::ClockService::milliseconds(700), 2, &handler));
78 // set timeout for termination
79 senf::scheduler::TimerEvent te_exit( "myexit", &myexit, t + senf::ClockService::milliseconds( 1000));
81 SENF_CHECK_NO_THROW( senf::scheduler::process() );
83 BOOST_CHECK( count == 2);
88 ///////////////////////////////cc.e////////////////////////////////////////
96 // c-file-style: "senf"
97 // indent-tabs-mode: nil
98 // ispell-local-dictionary: "american"
99 // compile-command: "scons -u test"