static void deactivate_timer(struct timer *timer) { if (timer->next) { timer->next->prev = timer->prev; } if (timer->prev) { timer->prev->next = timer->next; } if (timer->timer_service->active_end == timer) { timer->timer_service->active_end = timer->prev; } if (timer->timer_service->active == timer) { timer->timer_service->active = timer->next; } /* Put in the inactive */ timer->state = timer_cancelled_e; /* * If LL head is not null, then active_end must be non null else active_end * must be null */ assert((timer->timer_service->active != NULL) ? (timer->timer_service->active_end != NULL) : (timer->timer_service->active_end == NULL)); insert_inactive(timer); }
/* * Create a new timer object */ cap_t timer_server_create_impl(CORBA_Object _caller, objref_t timer_service, L4_ThreadId_t *thread, uintptr_t mask, idl4_server_environment * _env) { cap_t cap = { {0}, 0 }; L4_ThreadId_t subject_thread; struct timer *timer; timer = malloc(sizeof(struct timer)); assert(thread->raw != L4_myselfconst.raw); subject_thread = *thread; if (timer == NULL) { return cap; } /* XXX: We always use the global_timer_service. */ timer->timer_service = global_timer_service; timer->state = timer_cancelled_e; timer->thread = subject_thread; timer->mask = mask; insert_inactive(timer); cap.ref.obj = (uintptr_t)timer; /* * FIXME: set up a password */ return cap; }
int LRURowStorage<ROW, V>::PutRow(int32_t row_id, const ROW<V>& new_row) { // Look for row_id in active_list_. const typename MapList::left_iterator ait = active_list_.left.find(row_id); if (ait != active_list_.left.end()) { // We found row_id in active_list_. Update it. ait->second = new_row; // Now move it to the end of the list (most recent) active_list_.right.relocate( active_list_.right.end(), active_list_.project_right(ait)); return 0; // replace existing row. } // Look for row_id in inactive_list_. const inactive_list_left_iter_t iit = inactive_list_.left.find(row_id); if (iit != inactive_list_.left.end()) { // We found row_id in inactive_list_. AccessStatsRow& row_tuple = iit->second; // Update it. row_tuple.template get<AccessStatsRowTuple::DATA>() = new_row; row_tuple.template get<AccessStatsRowTuple::CURR_COUNT>() += new_row.get_num_columns(); // Recompute the threshold count. row_tuple.template get<AccessStatsRowTuple::THRESHOLD>() = static_cast<int>(num_row_access_to_active_ * new_row.get_num_columns()); PromoteInactiveRowOrRelocate(iit); return 0; // replace existing row. } // Not found in either list, put it in inactive_list_. insert_inactive(row_id, new_row); return 1; // inserting new row. }