timer-benchmarks icon indicating copy to clipboard operation
timer-benchmarks copied to clipboard

测试代码有崩溃,帮忙分析下原因~

Open 20083017 opened this issue 1 year ago • 0 comments

int64_t deadline = Clock::CurrentTimeMillis(); auto timer = CreateTimer(TimerSchedType::TIMER_HH_WHEEL); std::vector times = {15,10,5,3,2,10,5,3,2,1,2,1,1,2000}; auto delay = 0; std::cout << " start " << Clock::CurrentTimeMillis() << std::endl; uint32_t duration = 0; for (int i = 0; i < times.size(); i++) {

        duration += times[uint32_t(delay)%times.size()];
        std::cout << " duration " << duration << " cur ms: " << Clock::CurrentTimeMillis() << std::endl;
        int tid = timer->Start(duration, []() {

            std::cout << "client send 1111111        " << Clock::CurrentTimeMillis() << std::endl;


        });
        delay += 1;
    }
    for (int i = 0; i <= duration*2; i++) {
        timer->Update(Clock::CurrentTimeMillis());
        std::this_thread::sleep_for(std::chrono::nanoseconds(500 * 1000));
    }

20083017 avatar Dec 16 '24 12:12 20083017