ns-3 Direct Code Execution
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
rr-task-scheduler.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2008 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 #include "rr-task-scheduler.h"
21 #include "ns3/log.h"
22 
23 NS_LOG_COMPONENT_DEFINE ("RrTaskScheduler");
24 
25 namespace ns3 {
26 
27 NS_OBJECT_ENSURE_REGISTERED (RrTaskScheduler);
28 
29 TypeId
31 {
32  static TypeId tid = TypeId ("ns3::RrTaskScheduler")
33  .SetParent<TaskScheduler> ()
34  .AddConstructor<RrTaskScheduler> ()
35  ;
36  return tid;
37 }
39 {
40 }
41 
42 struct Task *
44 {
45  if (m_active.empty ())
46  {
47  return 0;
48  }
49  struct Task *task = m_active.front ();
50  NS_LOG_DEBUG ("next=" << task);
51  return task;
52 }
53 void
55 {
56  NS_LOG_FUNCTION (this);
57  NS_ASSERT (!m_active.empty ());
58  m_active.pop_front ();
59 }
60 void
62 {
63  NS_LOG_FUNCTION (this << task);
64  m_active.push_back (task);
65 }
66 void
68 {
69  NS_LOG_FUNCTION (this << task);
70  m_active.remove (task);
71 }
72 
73 } // namespace ns3