mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 08:37:46 +00:00
AK: Add Time::now_<clock_id> functions for obtaining the current time
In the quest of removing as timespec / timeval usage in the Userland as possible, we need a way to conveniently retrieving the current clock time from the kernel and storing it in `AK::Time` format.
This commit is contained in:
parent
188e5f018f
commit
dae17ce7e3
2 changed files with 39 additions and 0 deletions
|
@ -143,6 +143,13 @@ public:
|
|||
constexpr static Time zero() { return Time(0, 0); };
|
||||
constexpr static Time max() { return Time(0x7fff'ffff'ffff'ffffLL, 999'999'999); };
|
||||
|
||||
#ifndef KERNEL
|
||||
[[nodiscard]] static Time now_realtime();
|
||||
[[nodiscard]] static Time now_realtime_coarse();
|
||||
[[nodiscard]] static Time now_monotonic();
|
||||
[[nodiscard]] static Time now_monotonic_coarse();
|
||||
#endif
|
||||
|
||||
// Truncates towards zero (2.8s to 2s, -2.8s to -2s).
|
||||
i64 to_truncated_seconds() const;
|
||||
i64 to_truncated_milliseconds() const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue