src/BucketTimer.cpp
// do lazy cancellation, so we can effectively use vector as container of timer nodes
do lazy cancellation, so we can effectively use vector as container of timer nodes
do lazy cancellation so we can effectively use vector as container of timer nodes
bool BucketTimer::Cancel(const int timer_id)
{
    const auto itnode = hash_.find(timer_id);
    if (itnode == hash_.end())
        return false;
    auto node = itnode->second;
    auto& expire = node->expire;
    if (expire > 0)
        near_[expire % TVR_SIZE].erase(node->id);
    hash_.erase(itnode);
    expire = INVALID_NODE_TIMERID;
    freeNode(node);
    return true;
}
bool BucketTimer :: Cancel ( const int timer_id ) { const auto itnode = hash_ . find ( timer_id ) ; if ( itnode == hash_ . end ( ) ) return false ; auto node = itnode -> second ; auto & expire = node -> expire ; if ( expire > 0 ) near_ [ expire % TVR_SIZE ] . erase ( node -> id ) ; hash_ . erase ( itnode ) ; expire = INVALID_NODE_TIMERID ; freeNode ( node ) ; return true ; }
do lazy cancellation, so we can effectively use vector as container of timer nodes
do lazy cancellation so we can effectively use vector as container of timer nodes