OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 #ifndef TASK_MANAGER_H | 2 #ifndef TASK_MANAGER_H |
3 #define TASK_MANAGER_H | 3 #define TASK_MANAGER_H |
4 | 4 |
5 #include "ns3/object.h" | 5 #include "ns3/object.h" |
6 #include "ns3/event-id.h" | 6 #include "ns3/event-id.h" |
7 #include "ns3/nstime.h" | 7 #include "ns3/nstime.h" |
8 #include "task-scheduler.h" | 8 #include "task-scheduler.h" |
9 #include <list> | 9 #include <list> |
10 | 10 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 * need to call Unref on the object returned). This is done on purpose to avoi
d | 118 * need to call Unref on the object returned). This is done on purpose to avoi
d |
119 * problems due to a task calling Current, storing the reference on the stack, | 119 * problems due to a task calling Current, storing the reference on the stack, |
120 * calling Exit, and the destructor of the caller stack frame never being call
ed | 120 * calling Exit, and the destructor of the caller stack frame never being call
ed |
121 * during process unloading, hence resulting in a lost reference and a leak. | 121 * during process unloading, hence resulting in a lost reference and a leak. |
122 * This is also why we don't return a Ptr<TaskManager> because it would increa
se | 122 * This is also why we don't return a Ptr<TaskManager> because it would increa
se |
123 * the reference count and thus lose references when the caller's stack is rip
ped | 123 * the reference count and thus lose references when the caller's stack is rip
ped |
124 * out. | 124 * out. |
125 */ | 125 */ |
126 static TaskManager *Current (void); | 126 static TaskManager *Current (void); |
127 | 127 |
| 128 /** |
| 129 * Preempt the task to schedule. |
| 130 */ |
| 131 void EnterHiTask (Task *task); |
| 132 void LeaveHiTask (Task *task); |
| 133 |
128 void SetSwitchNotify (void (*fn)(void)); | 134 void SetSwitchNotify (void (*fn)(void)); |
129 uint32_t GetStackSize (Task *task) const; | 135 uint32_t GetStackSize (Task *task) const; |
130 private: | 136 private: |
131 enum FiberManagerType | 137 enum FiberManagerType |
132 { | 138 { |
133 UCONTEXT_FIBER_MANAGER, | 139 UCONTEXT_FIBER_MANAGER, |
134 PTHREAD_FIBER_MANAGER, | 140 PTHREAD_FIBER_MANAGER, |
135 }; | 141 }; |
136 struct StartTaskContext | 142 struct StartTaskContext |
137 { | 143 { |
138 void (*function)(void *); | 144 void (*function)(void *); |
139 void *context; | 145 void *context; |
140 }; | 146 }; |
141 | 147 |
142 virtual void DoDispose (void); | 148 virtual void DoDispose (void); |
143 void Schedule (void); | 149 void Schedule (void); |
144 void SetFiberManagerType (enum FiberManagerType type); | 150 void SetFiberManagerType (enum FiberManagerType type); |
145 void GarbageCollectDeadTasks (void); | 151 void GarbageCollectDeadTasks (void); |
146 void EndWait (Task *task); | 152 void EndWait (Task *task); |
147 static void Trampoline (void *context); | 153 static void Trampoline (void *context); |
148 | 154 |
149 Task *m_current; | 155 Task *m_current; |
| 156 Task *m_hightask; |
150 Ptr<TaskScheduler> m_scheduler; | 157 Ptr<TaskScheduler> m_scheduler; |
151 FiberManager *m_fiberManager; | 158 FiberManager *m_fiberManager; |
152 Fiber *m_mainFiber; | 159 Fiber *m_mainFiber; |
153 uint32_t m_defaultStackSize; | 160 uint32_t m_defaultStackSize; |
154 EventId m_nextSchedule; | 161 EventId m_nextSchedule; |
155 EventId m_nextGc; | 162 EventId m_nextGc; |
156 std::list<Task *> m_deadTasks; | 163 std::list<Task *> m_deadTasks; |
157 bool m_disposing; // In order to never loop while disposing me. | 164 bool m_disposing; // In order to never loop while disposing me. |
158 }; | 165 }; |
159 | 166 |
160 } // namespace | 167 } // namespace |
161 | 168 |
162 #endif /* TASK_MANAGER_H */ | 169 #endif /* TASK_MANAGER_H */ |
OLD | NEW |