void CEventDispatch::_CheckLoop() { for (list<TimerItem*>::iterator it = m_loop_list.begin(); it != m_loop_list.end(); it++) { TimerItem* pItem = *it; pItem->callback(pItem->user_data, NETLIB_MSG_LOOP, 0, NULL); } }
void CEventDispatch::_CheckTimer() { uint64_t curr_tick = get_tick_count(); list<TimerItem*>::iterator it; for (it = m_timer_list.begin(); it != m_timer_list.end(); ){ TimerItem* pItem = *it; it++; // iterator maybe deleted in the callback, so we should increment it before callback if (curr_tick >= pItem->next_tick){ pItem->next_tick += pItem->interval; pItem->callback(pItem->user_data, NETLIB_MSG_TIMER, 0, NULL); } } }