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 FIFORunner non-inline non-template implementation */
26 #include "FIFORunner.hh"
27 //#include "FIFORunner.ih"
31 //#include "FIFORunner.mpp"
33 ///////////////////////////////cc.p////////////////////////////////////////
35 prefix_ void senf::scheduler::FIFORunner::dequeue(TaskInfo * task)
37 TaskList::iterator i (TaskList::current(*task));
45 : public senf::scheduler::FIFORunner::TaskInfo
51 prefix_ void senf::scheduler::FIFORunner::run()
53 // This algorithm is carefully adjusted to make it work even when arbitrary tasks are removed
55 // - Before we begin, we add a NullTask to the queue. The only purpose of this node is, to mark
56 // the current end of the queue. The iterator to this node becomes the end iterator of the
58 // - We update the TaskInfo and move it to the end of the queue before calling the callback so
59 // we don't access the TaskInfo if it is removed while the callback is running
60 // - We keep the next to-be-processed node in a class variable which is checked and updated
61 // whenever a node is removed.
63 tasks_.push_back(null);
64 TaskList::iterator end (TaskList::current(null));
65 next_ = tasks_.begin();
66 while (next_ != end) {
67 TaskInfo & task (*next_);
69 task.runnable = false;
70 TaskList::iterator i (next_);
72 tasks_.splice(tasks_.end(), tasks_, i);
82 ///////////////////////////////cc.e////////////////////////////////////////
84 //#include "FIFORunner.mpp"
91 // c-file-style: "senf"
92 // indent-tabs-mode: nil
93 // ispell-local-dictionary: "american"
94 // compile-command: "scons -u test"