-
Notifications
You must be signed in to change notification settings - Fork 841
Update format string for formatting chrono duration #12684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
src/iocore/eventsystem/Watchdog.cc
Outdated
| Dbg(dbg_ctl_watchdog, "Starting watchdog with timeout %" PRIu64 " ms on %zu threads. sleep_time = %" PRIu64 " us", | ||
| _timeout.count(), _threads.size(), std::chrono::duration_cast<std::chrono::microseconds>(sleep_time).count()); | ||
| Dbg(dbg_ctl_watchdog, "Starting watchdog with timeout %lld ms on %zu threads. sleep_time = %lld us", _timeout.count(), | ||
| _threads.size(), std::chrono::duration_cast<std::chrono::microseconds>(sleep_time).count()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To deal with different numeric types for std::chrono::microseconds on different systems, how about:
_threads.size(), std::chrono::duration_cast<std::chrono::duration<long long, std::micro>>(sleep_time).count());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does seem like different vendors/versions have different types for rep. Madness!
| if (warned_seq < seq) { | ||
| // Warn once per loop iteration | ||
| Warning("Watchdog: [ET_NET %zu] has been awake for %" PRIu64 " ms", i, | ||
| Warning("Watchdog: [ET_NET %zu] has been awake for %lld ms", i, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise,
std::chrono::duration_cast<std::chrono::duration<long long, std::milli>>(awake_duration).count());
src/iocore/eventsystem/Watchdog.cc
Outdated
| std::chrono::duration_cast<std::chrono::duration<long long, std::milli>>(_timeout).count(), _threads.size(), | ||
| std::chrono::duration_cast<std::chrono::duration<long long, std::micro>>(sleep_time).count()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the compilers are happy with it. Can we put this in a using alias though?
bneradt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great.
Newer clang compilers want
%lldforlong longand%ldforlongand will warn otherwise. Unfortunately, there isn't a way to use thePRI*macros to producelldon 64 bit word systems.