Utils/Console: Fix singleton instantiation order (ServerManager / Scheduler)
[senf.git] / Scheduler / Scheduler.cc
1 // $Id$
2 //
3 // Copyright (C) 2006
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.de>
7 //
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.
12 //
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.
17 //
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.
22
23 /** \file
24     \brief Scheduler non-inline non-template implementation
25
26     \idea Multithreading support: To support multithreading, the
27     static member Scheduler::instance() must return a thread-local
28     value (that is Scheduler::instance() must allocate one Scheduler
29     instance per thread). Another possibility would be to distribute
30     the async load unto several threads (one scheduler for multiple
31     threads)
32  */
33
34 #include "Scheduler.hh"
35 //#include "Scheduler.ih"
36
37 // Custom includes
38
39 #define prefix_
40 ///////////////////////////////cc.p////////////////////////////////////////
41
42 prefix_ void senf::Scheduler::process()
43 {
44     terminate_ = false;
45     while(! terminate_ && ! (fdDispatcher_.empty() &&
46                              timerDispatcher_.empty() &&
47                              fileDispatcher_.empty())) {
48         signalDispatcher_.unblockSignals();
49         timerDispatcher_.unblockSignals();
50         manager_.processOnce();
51         timerDispatcher_.blockSignals();
52         signalDispatcher_.blockSignals();
53         fileDispatcher_.prepareRun();
54         runner_.run();
55     }
56 }
57
58 ///////////////////////////////////////////////////////////////////////////
59 // senf::SchedulerLogTimeSource
60
61 prefix_ senf::log::time_type senf::SchedulerLogTimeSource::operator()()
62     const
63 {
64     return Scheduler::instance().eventTime();
65 }
66
67 ///////////////////////////////cc.e////////////////////////////////////////
68 #undef prefix_
69
70 \f
71 // Local Variables:
72 // mode: c++
73 // fill-column: 100
74 // c-file-style: "senf"
75 // indent-tabs-mode: nil
76 // ispell-local-dictionary: "american"
77 // compile-command: "scons -u test"
78 // comment-column: 40
79 // End: