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.
23 /** \mainpage The SENF Scheduler Library
25 The %Scheduler Library provides a single-threaded application event-loop multiplexing multiple
30 \section scheduler_scheduler The Scheduler
31 \seechapter \ref senf::scheduler
33 The %scheduler provides a single threaded event dispatch architecture with reliable task
34 queueing using FIFO scheduling. The %scheduler provides event handling for
40 \section scheduler_clockservice The ClockService
41 \seechapter senf::ClockService
43 To support precise event timing, the senf::ClockService class implements a reliable monotonous
44 time source. It is based on the high precision POSIX clock and adds support for reliable
45 conversion between an abstract clock type and absolute date/time
47 \section scheduler_helpers Miscellaneous helpers
49 To ease the use of the Scheduler there are some additional helpers managing callbacks and
52 \li senf::ReadHelper reads data from an arbitrary file descritor until a use specified condition
53 is met (e.g. number of chars read or a specific character sequence is found in the input).
54 \li senf::WriteHelper writes data to an arbitrary file descriptor until all provided data has
57 \section scheduler_i Implementation
58 \seechapter \ref scheduler_implementation
60 senf::Scheduler is only a wrapper around the real implementation. The real implementation is now
61 based on a modular dispatcher architecture
65 /** \page scheduler_implementation The Scheduler Implementation
67 The implentation architecture now is based on a set of dispatchers, one for each type of
72 \section scheduler_i_overview Overview
74 The %scheduler utilizes the following components
76 \li There is a dispatcher for each event type. This dispatcher manages the event specific
77 registration and unregistration. The dispatcher is owns the event (and task) objects.
79 \li Every registered event is represented by an event specific event class instance.
81 \li The Dispatcher ultimately registeres with the senf::scheduler::detail::FdManager. Since the
82 event-loop is based on epoll() (it could easily be changed to be based on select() or
83 poll()), all events must ultimately be represented by some type of file descriptor (not
84 necessarily a \e different file descriptor for each event).
86 \li The Dispatcher registeres all callbacks as tasks with the runner
87 (senf::scheduler::detail::FIFORunner).
89 \li The senf::scheduler::detail::FdManager uses senf::scheduler::detail::Poller to access the
90 low-level epoll() API.
92 All these classes are singletons.
95 \section scheduler_i_dispatchers Dispatchers
97 There is a dispatcher for each event type
99 \li senf::scheduler::detail::FdDispatcher manages poll-able file descriptors. This does \e not
101 \li senf::scheduler::detail::FileDispatcher manages disk files
102 \li senf::scheduler::detail::TimerDispatcher manages timers
103 \li senf::scheduler::detail::SignalDispatcher manages UNIX signals
105 Each dispatcher has a specific API and the integration into the main-loop is not standardized
106 for performance reasons.
108 The Dispatcher does not own the event instances, instead those instances are owned by the
109 respective object creating the event. The implementation uses boost::intrusive containeres to
110 manage the events. This makes the Scheduler itself be completely devoid of dynamic memory
114 \section scheduler_i_mainloop The main loop
116 The application mainloop senf::scheduler::process() is constructed by calling the correct
117 members of all these classes repeatedly in the correct order:
119 \li First dispatchers are set up
120 \li then the senf::scheduler::FdManager is called to wait for an event
121 \li After cleaning up the dispatchers,
122 \li the senf::scheduler::FIFORunner is called to executed all now runnable tasks.
129 // c-file-style: "senf"
130 // indent-tabs-mode: nil
131 // ispell-local-dictionary: "american"
134 // compile-command: "scons -U doc"