生成唯一的Id

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/libaineu2004/article/details/86213356

可以吗?

int TimeWheel::GenerateTimerID()
{
    int x = rand() % 0xffffffff;
    int cur_time = time(nullptr);
    return x | cur_time | _timer_count;
}

int TimeWheel::AddTimer(int interval)
{
    timer_id = GenerateTimerID();
    _timer_count++;
    return timer_id;
}

猜你喜欢

转载自blog.csdn.net/libaineu2004/article/details/86213356