MCPcopy Create free account
hub / github.com/SIPp/sipp / task2list

Method task2list

src/task.cpp:164–197  ·  view source on GitHub ↗

Based on the time a given task should next be woken up, finds the correct time wheel for it and returns a list of other tasks occurring at that point.

Source from the content-addressed store, hash-verified

162// correct time wheel for it and returns a list of other tasks
163// occurring at that point.
164task_list *timewheel::task2list(task *task)
165{
166 unsigned int wake = task->wake();
167
168 if (wake == 0) {
169 return &forever_list;
170 }
171
172 assert(wake >= wheel_base);
173 if (wheel_base > clock_tick) {
174 ERROR("wheel_base is %lu, clock_tick is %lu - expected wheel_base to be less than or equal to clock_tick", wheel_base, clock_tick);
175 assert(wheel_base <= clock_tick);
176 }
177
178 unsigned int slot_in_first_wheel = wake % LEVEL_ONE_SLOTS;
179 unsigned int slot_in_second_wheel = (wake / LEVEL_ONE_SLOTS) % LEVEL_TWO_SLOTS;
180 unsigned int slot_in_third_wheel = (wake / (LEVEL_ONE_SLOTS * LEVEL_TWO_SLOTS));
181
182 bool fits_in_first_wheel = ((wake / LEVEL_ONE_SLOTS) == (wheel_base / LEVEL_ONE_SLOTS));
183 bool fits_in_second_wheel = ((wake / (LEVEL_ONE_SLOTS * LEVEL_TWO_SLOTS)) ==
184 (wheel_base / (LEVEL_ONE_SLOTS * LEVEL_TWO_SLOTS)));
185 bool fits_in_third_wheel = (slot_in_third_wheel < LEVEL_THREE_SLOTS);
186
187 if (fits_in_first_wheel) {
188 return &wheel_one[slot_in_first_wheel];
189 } else if (fits_in_second_wheel) {
190 return &wheel_two[slot_in_second_wheel];
191 } else if (fits_in_third_wheel) {
192 return &wheel_three[slot_in_third_wheel];
193 } else{
194 ERROR("Attempted to schedule a task too far in the future");
195 return nullptr;
196 }
197}
198
199/* Iterate through our sorted set of paused tasks, removing those that
200 * should no longer be paused, and adding them to the run queue. */

Callers

nothing calls this directly

Calls 2

ERRORFunction · 0.85
wakeMethod · 0.45

Tested by

no test coverage detected