scheduler.hh (13076:c9e2a8bfe907) scheduler.hh (13078:f11496886d1a)
1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright

--- 224 unchanged lines hidden (view full) ---

233 ts->events.insert(event);
234 }
235
236 // For descheduling delayed/timed notifications/timeouts.
237 void
238 deschedule(ScEvent *event)
239 {
240 if (event->when() == getCurTick()) {
1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright

--- 224 unchanged lines hidden (view full) ---

233 ts->events.insert(event);
234 }
235
236 // For descheduling delayed/timed notifications/timeouts.
237 void
238 deschedule(ScEvent *event)
239 {
240 if (event->when() == getCurTick()) {
241 // Remove from delta notifications.
242 deltas.erase(event);
243 event->deschedule();
244 return;
241 // Attempt to remove from delta notifications.
242 if (deltas.erase(event) == 1) {
243 event->deschedule();
244 return;
245 }
245 }
246
247 // Timed notification/timeout.
248 auto tsit = timeSlots.find(event->when());
249 panic_if(tsit == timeSlots.end(),
250 "Descheduling event at time with no events.");
251 TimeSlot *ts = tsit->second;
252 ScEvents &events = ts->events;
246 }
247
248 // Timed notification/timeout.
249 auto tsit = timeSlots.find(event->when());
250 panic_if(tsit == timeSlots.end(),
251 "Descheduling event at time with no events.");
252 TimeSlot *ts = tsit->second;
253 ScEvents &events = ts->events;
253 events.erase(event);
254 assert(events.erase(event));
254 event->deschedule();
255
256 // If no more events are happening at this time slot, get rid of it.
257 if (events.empty()) {
258 deschedule(ts);
259 timeSlots.erase(tsit);
260 }
261 }

--- 147 unchanged lines hidden ---
255 event->deschedule();
256
257 // If no more events are happening at this time slot, get rid of it.
258 if (events.empty()) {
259 deschedule(ts);
260 timeSlots.erase(tsit);
261 }
262 }

--- 147 unchanged lines hidden ---