Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

[BUG] Execute point is not right #13

@gzliurc

Description

@gzliurc
uint64_t check_point_1_last = TimeUtil::GetNowMillsecond();
uint64_t check_point_2_last = TimeUtil::GetNowMillsecond();
dp::periodic_function<std::function<void()>, dp::policies::schedule_next_missed_interval_policy> fu([&]() {
    auto now = TimeUtil::GetNowMillsecond();
    LOGD << "Check Point 1::" << (now - check_point_1_last);
    check_point_1_last = now;
    this_thread::sleep_for(chrono::milliseconds(1000));
    now = TimeUtil::GetNowMillsecond();
    LOGD << "Check Point 2::" << (now - check_point_2_last);
    check_point_2_last = now;
}, chrono::milliseconds(5000));
fu.start();

//LOG is
2020-10-29 17:34:49.677 DEBUG [1142] [main@36] Check Point 1::5001
2020-10-29 17:34:50.679 DEBUG [1142] [main@40] Check Point 2::6003
2020-10-29 17:34:53.674 DEBUG [1142] [main@36] Check Point 1::3997
2020-10-29 17:34:54.675 DEBUG [1142] [main@40] Check Point 2::3996
2020-10-29 17:34:57.674 DEBUG [1142] [main@36] Check Point 1::4000
2020-10-29 17:34:58.675 DEBUG [1142] [main@40] Check Point 2::4000
2020-10-29 17:35:01.673 DEBUG [1142] [main@36] Check Point 1::3999
2020-10-29 17:35:02.673 DEBUG [1142] [main@40] Check Point 2::3998
2020-10-29 17:35:05.672 DEBUG [1142] [main@36] Check Point 1::3999
2020-10-29 17:35:06.673 DEBUG [1142] [main@40] Check Point 2::4000

if i change sleep to 2000ms
2020-10-29 17:36:17.804 DEBUG [1172] [main@36] Check Point 1::5001
2020-10-29 17:36:19.807 DEBUG [1172] [main@40] Check Point 2::7004
2020-10-29 17:36:20.802 DEBUG [1172] [main@36] Check Point 1::2998
2020-10-29 17:36:22.802 DEBUG [1172] [main@40] Check Point 2::2995
2020-10-29 17:36:23.801 DEBUG [1172] [main@36] Check Point 1::2999
2020-10-29 17:36:25.802 DEBUG [1172] [main@40] Check Point 2::3000
2020-10-29 17:36:26.801 DEBUG [1172] [main@36] Check Point 1::3000
2020-10-29 17:36:28.802 DEBUG [1172] [main@40] Check Point 2::3000
2020-10-29 17:36:29.801 DEBUG [1172] [main@36] Check Point 1::3000

Period is not at right timing.
expect check point 1 should be 5000ms

when i change sleep to random 1000~2000ms
2020-10-29 17:42:34.360 DEBUG [1202] [main@36] Check Point 1::5001
2020-10-29 17:42:35.388 DEBUG [1202] [main@40] Check Point 2::6029
2020-10-29 17:42:38.331 DEBUG [1202] [main@36] Check Point 1::3971
2020-10-29 17:42:40.328 DEBUG [1202] [main@40] Check Point 2::4940
2020-10-29 17:42:41.335 DEBUG [1202] [main@36] Check Point 1::3004
2020-10-29 17:42:42.914 DEBUG [1202] [main@40] Check Point 2::2586
2020-10-29 17:42:44.757 DEBUG [1202] [main@36] Check Point 1::3422
2020-10-29 17:42:46.735 DEBUG [1202] [main@40] Check Point 2::3821
2020-10-29 17:42:47.781 DEBUG [1202] [main@36] Check Point 1::3024
2020-10-29 17:42:49.433 DEBUG [1202] [main@40] Check Point 2::2698

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions