summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Arch/x86_64/RTC.cpp4
-rw-r--r--Kernel/Arch/x86_64/RTC.h3
-rw-r--r--Kernel/Bus/USB/UHCI/UHCIController.cpp4
-rw-r--r--Kernel/Devices/AsyncDeviceRequest.cpp2
-rw-r--r--Kernel/Devices/AsyncDeviceRequest.h2
-rw-r--r--Kernel/Devices/Audio/IntelHDA/Stream.cpp2
-rw-r--r--Kernel/FileSystem/DevPtsFS/Inode.cpp2
-rw-r--r--Kernel/FileSystem/Ext2FS/Inode.cpp10
-rw-r--r--Kernel/FileSystem/Ext2FS/Inode.h2
-rw-r--r--Kernel/FileSystem/ISO9660FS/Inode.cpp4
-rw-r--r--Kernel/FileSystem/ISO9660FS/Inode.h2
-rw-r--r--Kernel/FileSystem/Inode.cpp2
-rw-r--r--Kernel/FileSystem/Inode.h2
-rw-r--r--Kernel/FileSystem/InodeMetadata.h8
-rw-r--r--Kernel/FileSystem/ProcFS/Inode.h2
-rw-r--r--Kernel/FileSystem/RAMFS/Inode.cpp2
-rw-r--r--Kernel/FileSystem/RAMFS/Inode.h2
-rw-r--r--Kernel/FileSystem/SysFS/Inode.cpp2
-rw-r--r--Kernel/FileSystem/SysFS/Inode.h2
-rw-r--r--Kernel/FileSystem/VirtualFileSystem.cpp6
-rw-r--r--Kernel/Graphics/VMWare/Console.cpp2
-rw-r--r--Kernel/Graphics/VirtIOGPU/Console.cpp2
-rw-r--r--Kernel/Net/IPv4Socket.cpp6
-rw-r--r--Kernel/Net/IPv4Socket.h8
-rw-r--r--Kernel/Net/LocalSocket.cpp2
-rw-r--r--Kernel/Net/LocalSocket.h2
-rw-r--r--Kernel/Net/NetworkAdapter.cpp2
-rw-r--r--Kernel/Net/NetworkAdapter.h6
-rw-r--r--Kernel/Net/NetworkTask.cpp22
-rw-r--r--Kernel/Net/Socket.cpp2
-rw-r--r--Kernel/Net/Socket.h14
-rw-r--r--Kernel/Net/TCPSocket.cpp4
-rw-r--r--Kernel/Net/TCPSocket.h4
-rw-r--r--Kernel/PerformanceManager.h6
-rw-r--r--Kernel/Process.cpp2
-rw-r--r--Kernel/Process.h2
-rw-r--r--Kernel/StdLib.cpp16
-rw-r--r--Kernel/StdLib.h6
-rw-r--r--Kernel/Storage/NVMe/NVMeController.cpp2
-rw-r--r--Kernel/Storage/NVMe/NVMeController.h2
-rw-r--r--Kernel/Syscalls/alarm.cpp4
-rw-r--r--Kernel/Syscalls/beep.cpp2
-rw-r--r--Kernel/Syscalls/clock.cpp4
-rw-r--r--Kernel/Syscalls/resource.cpp8
-rw-r--r--Kernel/Syscalls/socket.cpp2
-rw-r--r--Kernel/Tasks/SyncTask.cpp2
-rw-r--r--Kernel/Thread.cpp4
-rw-r--r--Kernel/Thread.h22
-rw-r--r--Kernel/ThreadBlockers.cpp10
-rw-r--r--Kernel/Time/TimeManagement.cpp34
-rw-r--r--Kernel/Time/TimeManagement.h22
-rw-r--r--Kernel/TimerQueue.cpp8
-rw-r--r--Kernel/TimerQueue.h14
53 files changed, 157 insertions, 156 deletions
diff --git a/Kernel/Arch/x86_64/RTC.cpp b/Kernel/Arch/x86_64/RTC.cpp
index e7a8cd48f8..d932e5b422 100644
--- a/Kernel/Arch/x86_64/RTC.cpp
+++ b/Kernel/Arch/x86_64/RTC.cpp
@@ -19,9 +19,9 @@ void initialize()
s_boot_time = now();
}
-Time boot_time()
+Duration boot_time()
{
- return Time::from_timespec({ s_boot_time, 0 });
+ return Duration::from_timespec({ s_boot_time, 0 });
}
static bool update_in_progress()
diff --git a/Kernel/Arch/x86_64/RTC.h b/Kernel/Arch/x86_64/RTC.h
index 80e49ff1e7..859baa82d7 100644
--- a/Kernel/Arch/x86_64/RTC.h
+++ b/Kernel/Arch/x86_64/RTC.h
@@ -6,12 +6,13 @@
#pragma once
+#include <AK/Time.h>
#include <Kernel/UnixTypes.h>
namespace Kernel::RTC {
void initialize();
time_t now();
-Time boot_time();
+Duration boot_time();
}
diff --git a/Kernel/Bus/USB/UHCI/UHCIController.cpp b/Kernel/Bus/USB/UHCI/UHCIController.cpp
index a2411ee526..ce373e7acb 100644
--- a/Kernel/Bus/USB/UHCI/UHCIController.cpp
+++ b/Kernel/Bus/USB/UHCI/UHCIController.cpp
@@ -590,7 +590,7 @@ ErrorOr<void> UHCIController::spawn_port_process()
if (m_root_hub)
m_root_hub->check_for_port_updates();
- (void)Thread::current()->sleep(Time::from_seconds(1));
+ (void)Thread::current()->sleep(Duration::from_seconds(1));
}
}));
return {};
@@ -616,7 +616,7 @@ ErrorOr<void> UHCIController::spawn_async_poll_process()
}
}
}
- (void)Thread::current()->sleep(Time::from_milliseconds(poll_interval_ms));
+ (void)Thread::current()->sleep(Duration::from_milliseconds(poll_interval_ms));
}
}));
return {};
diff --git a/Kernel/Devices/AsyncDeviceRequest.cpp b/Kernel/Devices/AsyncDeviceRequest.cpp
index 2a70a28b28..a45f70dea0 100644
--- a/Kernel/Devices/AsyncDeviceRequest.cpp
+++ b/Kernel/Devices/AsyncDeviceRequest.cpp
@@ -51,7 +51,7 @@ void AsyncDeviceRequest::request_finished()
m_queue.wake_all();
}
-auto AsyncDeviceRequest::wait(Time* timeout) -> RequestWaitResult
+auto AsyncDeviceRequest::wait(Duration* timeout) -> RequestWaitResult
{
VERIFY(!m_parent_request);
auto request_result = get_request_result();
diff --git a/Kernel/Devices/AsyncDeviceRequest.h b/Kernel/Devices/AsyncDeviceRequest.h
index 350ded3d11..8e9d57610c 100644
--- a/Kernel/Devices/AsyncDeviceRequest.h
+++ b/Kernel/Devices/AsyncDeviceRequest.h
@@ -60,7 +60,7 @@ public:
void add_sub_request(NonnullLockRefPtr<AsyncDeviceRequest>);
- [[nodiscard]] RequestWaitResult wait(Time* = nullptr);
+ [[nodiscard]] RequestWaitResult wait(Duration* = nullptr);
void do_start(SpinlockLocker<Spinlock<LockRank::None>>&& requests_lock)
{
diff --git a/Kernel/Devices/Audio/IntelHDA/Stream.cpp b/Kernel/Devices/Audio/IntelHDA/Stream.cpp
index 52f8a886ae..d7eb1ee7e7 100644
--- a/Kernel/Devices/Audio/IntelHDA/Stream.cpp
+++ b/Kernel/Devices/Audio/IntelHDA/Stream.cpp
@@ -192,7 +192,7 @@ ErrorOr<size_t> OutputStream::write(UserOrKernelBuffer const& data, size_t lengt
dbgln_if(INTEL_HDA_DEBUG, "IntelHDA: Waiting {} ยตs until buffer {} becomes writeable", microseconds_to_wait, buffer_index);
// NOTE: we don't care about the reason for interruption - we simply calculate the next delay
- [[maybe_unused]] auto block_result = Thread::current()->sleep(Time::from_microseconds(microseconds_to_wait));
+ [[maybe_unused]] auto block_result = Thread::current()->sleep(Duration::from_microseconds(microseconds_to_wait));
}
};
diff --git a/Kernel/FileSystem/DevPtsFS/Inode.cpp b/Kernel/FileSystem/DevPtsFS/Inode.cpp
index 92f3de94b6..419d73c5bc 100644
--- a/Kernel/FileSystem/DevPtsFS/Inode.cpp
+++ b/Kernel/FileSystem/DevPtsFS/Inode.cpp
@@ -38,7 +38,7 @@ InodeMetadata DevPtsFSInode::metadata() const
{
if (auto pty = m_pty.strong_ref()) {
auto metadata = m_metadata;
- metadata.mtime = Time::from_timespec({ pty->time_of_last_write(), 0 });
+ metadata.mtime = Duration::from_timespec({ pty->time_of_last_write(), 0 });
return metadata;
}
return m_metadata;
diff --git a/Kernel/FileSystem/Ext2FS/Inode.cpp b/Kernel/FileSystem/Ext2FS/Inode.cpp
index 3698cc6467..dfd50f124d 100644
--- a/Kernel/FileSystem/Ext2FS/Inode.cpp
+++ b/Kernel/FileSystem/Ext2FS/Inode.cpp
@@ -474,10 +474,10 @@ InodeMetadata Ext2FSInode::metadata() const
metadata.uid = m_raw_inode.i_uid;
metadata.gid = m_raw_inode.i_gid;
metadata.link_count = m_raw_inode.i_links_count;
- metadata.atime = Time::from_timespec({ m_raw_inode.i_atime, 0 });
- metadata.ctime = Time::from_timespec({ m_raw_inode.i_ctime, 0 });
- metadata.mtime = Time::from_timespec({ m_raw_inode.i_mtime, 0 });
- metadata.dtime = Time::from_timespec({ m_raw_inode.i_dtime, 0 });
+ metadata.atime = Duration::from_timespec({ m_raw_inode.i_atime, 0 });
+ metadata.ctime = Duration::from_timespec({ m_raw_inode.i_ctime, 0 });
+ metadata.mtime = Duration::from_timespec({ m_raw_inode.i_mtime, 0 });
+ metadata.dtime = Duration::from_timespec({ m_raw_inode.i_dtime, 0 });
metadata.block_size = fs().block_size();
metadata.block_count = m_raw_inode.i_blocks;
@@ -985,7 +985,7 @@ ErrorOr<NonnullRefPtr<Inode>> Ext2FSInode::lookup(StringView name)
return fs().get_inode({ fsid(), inode_index });
}
-ErrorOr<void> Ext2FSInode::update_timestamps(Optional<Time> atime, Optional<Time> ctime, Optional<Time> mtime)
+ErrorOr<void> Ext2FSInode::update_timestamps(Optional<Duration> atime, Optional<Duration> ctime, Optional<Duration> mtime)
{
MutexLocker locker(m_inode_lock);
if (fs().is_readonly())
diff --git a/Kernel/FileSystem/Ext2FS/Inode.h b/Kernel/FileSystem/Ext2FS/Inode.h
index 53e2f664ce..cc6acab147 100644
--- a/Kernel/FileSystem/Ext2FS/Inode.h
+++ b/Kernel/FileSystem/Ext2FS/Inode.h
@@ -37,7 +37,7 @@ private:
virtual ErrorOr<void> add_child(Inode& child, StringView name, mode_t) override;
virtual ErrorOr<void> remove_child(StringView name) override;
virtual ErrorOr<void> replace_child(StringView name, Inode& child) override;
- virtual ErrorOr<void> update_timestamps(Optional<Time> atime, Optional<Time> ctime, Optional<Time> mtime) override;
+ virtual ErrorOr<void> update_timestamps(Optional<Duration> atime, Optional<Duration> ctime, Optional<Duration> mtime) override;
virtual ErrorOr<void> increment_link_count() override;
virtual ErrorOr<void> decrement_link_count() override;
virtual ErrorOr<void> chmod(mode_t) override;
diff --git a/Kernel/FileSystem/ISO9660FS/Inode.cpp b/Kernel/FileSystem/ISO9660FS/Inode.cpp
index 4f6f7c3b2d..2a1dc195fa 100644
--- a/Kernel/FileSystem/ISO9660FS/Inode.cpp
+++ b/Kernel/FileSystem/ISO9660FS/Inode.cpp
@@ -145,7 +145,7 @@ ErrorOr<void> ISO9660Inode::truncate(u64)
return EROFS;
}
-ErrorOr<void> ISO9660Inode::update_timestamps(Optional<Time>, Optional<Time>, Optional<Time>)
+ErrorOr<void> ISO9660Inode::update_timestamps(Optional<Duration>, Optional<Duration>, Optional<Duration>)
{
return EROFS;
}
@@ -169,7 +169,7 @@ void ISO9660Inode::create_metadata()
{
u32 data_length = LittleEndian { m_record.data_length.little };
bool is_directory = has_flag(m_record.file_flags, ISO::FileFlags::Directory);
- auto recorded_at = Time::from_timespec({ parse_numerical_date_time(m_record.recording_date_and_time), 0 });
+ auto recorded_at = Duration::from_timespec({ parse_numerical_date_time(m_record.recording_date_and_time), 0 });
m_metadata = {
.inode = identifier(),
diff --git a/Kernel/FileSystem/ISO9660FS/Inode.h b/Kernel/FileSystem/ISO9660FS/Inode.h
index 76641431a3..06ba006205 100644
--- a/Kernel/FileSystem/ISO9660FS/Inode.h
+++ b/Kernel/FileSystem/ISO9660FS/Inode.h
@@ -32,7 +32,7 @@ public:
virtual ErrorOr<void> chmod(mode_t) override;
virtual ErrorOr<void> chown(UserID, GroupID) override;
virtual ErrorOr<void> truncate(u64) override;
- virtual ErrorOr<void> update_timestamps(Optional<Time> atime, Optional<Time> ctime, Optional<Time> mtime) override;
+ virtual ErrorOr<void> update_timestamps(Optional<Duration> atime, Optional<Duration> ctime, Optional<Duration> mtime) override;
private:
// HACK: The base ISO 9660 standard says the maximum filename length is 37
diff --git a/Kernel/FileSystem/Inode.cpp b/Kernel/FileSystem/Inode.cpp
index aab18cf1c3..5e2809ef9e 100644
--- a/Kernel/FileSystem/Inode.cpp
+++ b/Kernel/FileSystem/Inode.cpp
@@ -115,7 +115,7 @@ ErrorOr<size_t> Inode::read_until_filled_or_end(off_t offset, size_t length, Use
return length - remaining_length;
}
-ErrorOr<void> Inode::update_timestamps([[maybe_unused]] Optional<Time> atime, [[maybe_unused]] Optional<Time> ctime, [[maybe_unused]] Optional<Time> mtime)
+ErrorOr<void> Inode::update_timestamps([[maybe_unused]] Optional<Duration> atime, [[maybe_unused]] Optional<Duration> ctime, [[maybe_unused]] Optional<Duration> mtime)
{
return ENOTIMPL;
}
diff --git a/Kernel/FileSystem/Inode.h b/Kernel/FileSystem/Inode.h
index 938bf86737..5bd7298c5f 100644
--- a/Kernel/FileSystem/Inode.h
+++ b/Kernel/FileSystem/Inode.h
@@ -82,7 +82,7 @@ public:
bool is_metadata_dirty() const { return m_metadata_dirty; }
- virtual ErrorOr<void> update_timestamps(Optional<Time> atime, Optional<Time> ctime, Optional<Time> mtime);
+ virtual ErrorOr<void> update_timestamps(Optional<Duration> atime, Optional<Duration> ctime, Optional<Duration> mtime);
virtual ErrorOr<void> increment_link_count();
virtual ErrorOr<void> decrement_link_count();
diff --git a/Kernel/FileSystem/InodeMetadata.h b/Kernel/FileSystem/InodeMetadata.h
index e6300f6146..6cd5e77e90 100644
--- a/Kernel/FileSystem/InodeMetadata.h
+++ b/Kernel/FileSystem/InodeMetadata.h
@@ -120,10 +120,10 @@ struct InodeMetadata {
UserID uid { 0 };
GroupID gid { 0 };
nlink_t link_count { 0 };
- Time atime {};
- Time ctime {};
- Time mtime {};
- Time dtime {};
+ Duration atime {};
+ Duration ctime {};
+ Duration mtime {};
+ Duration dtime {};
blkcnt_t block_count { 0 };
blksize_t block_size { 0 };
MajorNumber major_device { 0 };
diff --git a/Kernel/FileSystem/ProcFS/Inode.h b/Kernel/FileSystem/ProcFS/Inode.h
index d060293dd8..97ebb4fa92 100644
--- a/Kernel/FileSystem/ProcFS/Inode.h
+++ b/Kernel/FileSystem/ProcFS/Inode.h
@@ -54,7 +54,7 @@ private:
// ^Inode (Silent ignore handling)
virtual ErrorOr<void> flush_metadata() override { return {}; }
- virtual ErrorOr<void> update_timestamps(Optional<Time>, Optional<Time>, Optional<Time>) override { return {}; }
+ virtual ErrorOr<void> update_timestamps(Optional<Duration>, Optional<Duration>, Optional<Duration>) override { return {}; }
// ^Inode
virtual ErrorOr<void> attach(OpenFileDescription& description) override;
diff --git a/Kernel/FileSystem/RAMFS/Inode.cpp b/Kernel/FileSystem/RAMFS/Inode.cpp
index 0441a34c46..5de6cd654e 100644
--- a/Kernel/FileSystem/RAMFS/Inode.cpp
+++ b/Kernel/FileSystem/RAMFS/Inode.cpp
@@ -381,7 +381,7 @@ ErrorOr<void> RAMFSInode::truncate(u64 size)
return {};
}
-ErrorOr<void> RAMFSInode::update_timestamps(Optional<Time> atime, Optional<Time> ctime, Optional<Time> mtime)
+ErrorOr<void> RAMFSInode::update_timestamps(Optional<Duration> atime, Optional<Duration> ctime, Optional<Duration> mtime)
{
MutexLocker locker(m_inode_lock);
diff --git a/Kernel/FileSystem/RAMFS/Inode.h b/Kernel/FileSystem/RAMFS/Inode.h
index 72ddeb0ea3..2d6a07a2e3 100644
--- a/Kernel/FileSystem/RAMFS/Inode.h
+++ b/Kernel/FileSystem/RAMFS/Inode.h
@@ -35,7 +35,7 @@ public:
virtual ErrorOr<void> chmod(mode_t) override;
virtual ErrorOr<void> chown(UserID, GroupID) override;
virtual ErrorOr<void> truncate(u64) override;
- virtual ErrorOr<void> update_timestamps(Optional<Time> atime, Optional<Time> ctime, Optional<Time> mtime) override;
+ virtual ErrorOr<void> update_timestamps(Optional<Duration> atime, Optional<Duration> ctime, Optional<Duration> mtime) override;
private:
RAMFSInode(RAMFS& fs, InodeMetadata const& metadata, LockWeakPtr<RAMFSInode> parent);
diff --git a/Kernel/FileSystem/SysFS/Inode.cpp b/Kernel/FileSystem/SysFS/Inode.cpp
index 626167b8d3..daa42dff93 100644
--- a/Kernel/FileSystem/SysFS/Inode.cpp
+++ b/Kernel/FileSystem/SysFS/Inode.cpp
@@ -110,7 +110,7 @@ ErrorOr<void> SysFSInode::truncate(u64 size)
return m_associated_component->truncate(size);
}
-ErrorOr<void> SysFSInode::update_timestamps(Optional<Time>, Optional<Time>, Optional<Time>)
+ErrorOr<void> SysFSInode::update_timestamps(Optional<Duration>, Optional<Duration>, Optional<Duration>)
{
return {};
}
diff --git a/Kernel/FileSystem/SysFS/Inode.h b/Kernel/FileSystem/SysFS/Inode.h
index c313a337ed..172cd6290e 100644
--- a/Kernel/FileSystem/SysFS/Inode.h
+++ b/Kernel/FileSystem/SysFS/Inode.h
@@ -35,7 +35,7 @@ protected:
virtual ErrorOr<void> chmod(mode_t) override;
virtual ErrorOr<void> chown(UserID, GroupID) override;
virtual ErrorOr<void> truncate(u64) override;
- virtual ErrorOr<void> update_timestamps(Optional<Time> atime, Optional<Time> ctime, Optional<Time> mtime) override;
+ virtual ErrorOr<void> update_timestamps(Optional<Duration> atime, Optional<Duration> ctime, Optional<Duration> mtime) override;
virtual ErrorOr<void> attach(OpenFileDescription& description) override final;
virtual void did_seek(OpenFileDescription&, off_t) override final;
diff --git a/Kernel/FileSystem/VirtualFileSystem.cpp b/Kernel/FileSystem/VirtualFileSystem.cpp
index a381305f25..4a65e0cca9 100644
--- a/Kernel/FileSystem/VirtualFileSystem.cpp
+++ b/Kernel/FileSystem/VirtualFileSystem.cpp
@@ -306,7 +306,7 @@ ErrorOr<void> VirtualFileSystem::utime(Credentials const& credentials, StringVie
if (custody->is_readonly())
return EROFS;
- TRY(inode.update_timestamps(Time::from_timespec({ atime, 0 }), {}, Time::from_timespec({ mtime, 0 })));
+ TRY(inode.update_timestamps(Duration::from_timespec({ atime, 0 }), {}, Duration::from_timespec({ mtime, 0 })));
return {};
}
@@ -326,9 +326,9 @@ ErrorOr<void> VirtualFileSystem::do_utimens(Credentials const& credentials, Cust
// NOTE: A standard ext2 inode cannot store nanosecond timestamps.
TRY(inode.update_timestamps(
- (atime.tv_nsec != UTIME_OMIT) ? Time::from_timespec(atime) : Optional<Time> {},
+ (atime.tv_nsec != UTIME_OMIT) ? Duration::from_timespec(atime) : Optional<Duration> {},
{},
- (mtime.tv_nsec != UTIME_OMIT) ? Time::from_timespec(mtime) : Optional<Time> {}));
+ (mtime.tv_nsec != UTIME_OMIT) ? Duration::from_timespec(mtime) : Optional<Duration> {}));
return {};
}
diff --git a/Kernel/Graphics/VMWare/Console.cpp b/Kernel/Graphics/VMWare/Console.cpp
index b55bab0722..033caa21a4 100644
--- a/Kernel/Graphics/VMWare/Console.cpp
+++ b/Kernel/Graphics/VMWare/Console.cpp
@@ -9,7 +9,7 @@
namespace Kernel {
-constexpr static AK::Time refresh_interval = AK::Time::from_milliseconds(16);
+constexpr static AK::Duration refresh_interval = AK::Duration::from_milliseconds(16);
NonnullLockRefPtr<VMWareFramebufferConsole> VMWareFramebufferConsole::initialize(VMWareDisplayConnector& parent_display_connector)
{
diff --git a/Kernel/Graphics/VirtIOGPU/Console.cpp b/Kernel/Graphics/VirtIOGPU/Console.cpp
index 2979af1421..57a338fcdf 100644
--- a/Kernel/Graphics/VirtIOGPU/Console.cpp
+++ b/Kernel/Graphics/VirtIOGPU/Console.cpp
@@ -10,7 +10,7 @@
namespace Kernel::Graphics::VirtIOGPU {
-constexpr static AK::Time refresh_interval = AK::Time::from_milliseconds(16);
+constexpr static AK::Duration refresh_interval = AK::Duration::from_milliseconds(16);
NonnullLockRefPtr<Console> Console::initialize(VirtIODisplayConnector& parent_display_connector)
{
diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp
index 61bdb59441..4094701265 100644
--- a/Kernel/Net/IPv4Socket.cpp
+++ b/Kernel/Net/IPv4Socket.cpp
@@ -287,7 +287,7 @@ ErrorOr<size_t> IPv4Socket::receive_byte_buffered(OpenFileDescription& descripti
return nreceived_or_error;
}
-ErrorOr<size_t> IPv4Socket::receive_packet_buffered(OpenFileDescription& description, UserOrKernelBuffer& buffer, size_t buffer_length, int flags, Userspace<sockaddr*> addr, Userspace<socklen_t*> addr_length, Time& packet_timestamp, bool blocking)
+ErrorOr<size_t> IPv4Socket::receive_packet_buffered(OpenFileDescription& description, UserOrKernelBuffer& buffer, size_t buffer_length, int flags, Userspace<sockaddr*> addr, Userspace<socklen_t*> addr_length, Duration& packet_timestamp, bool blocking)
{
MutexLocker locker(mutex());
ReceivedPacket taken_packet;
@@ -382,7 +382,7 @@ ErrorOr<size_t> IPv4Socket::receive_packet_buffered(OpenFileDescription& descrip
return protocol_receive(packet->data->bytes(), buffer, buffer_length, flags);
}
-ErrorOr<size_t> IPv4Socket::recvfrom(OpenFileDescription& description, UserOrKernelBuffer& buffer, size_t buffer_length, int flags, Userspace<sockaddr*> user_addr, Userspace<socklen_t*> user_addr_length, Time& packet_timestamp, bool blocking)
+ErrorOr<size_t> IPv4Socket::recvfrom(OpenFileDescription& description, UserOrKernelBuffer& buffer, size_t buffer_length, int flags, Userspace<sockaddr*> user_addr, Userspace<socklen_t*> user_addr_length, Duration& packet_timestamp, bool blocking)
{
if (user_addr_length) {
socklen_t addr_length;
@@ -415,7 +415,7 @@ ErrorOr<size_t> IPv4Socket::recvfrom(OpenFileDescription& description, UserOrKer
return total_nreceived;
}
-bool IPv4Socket::did_receive(IPv4Address const& source_address, u16 source_port, ReadonlyBytes packet, Time const& packet_timestamp)
+bool IPv4Socket::did_receive(IPv4Address const& source_address, u16 source_port, ReadonlyBytes packet, Duration const& packet_timestamp)
{
MutexLocker locker(mutex());
diff --git a/Kernel/Net/IPv4Socket.h b/Kernel/Net/IPv4Socket.h
index 3cc5d360e7..2518df798b 100644
--- a/Kernel/Net/IPv4Socket.h
+++ b/Kernel/Net/IPv4Socket.h
@@ -40,13 +40,13 @@ public:
virtual bool can_read(OpenFileDescription const&, u64) const override;
virtual bool can_write(OpenFileDescription const&, u64) const override;
virtual ErrorOr<size_t> sendto(OpenFileDescription&, UserOrKernelBuffer const&, size_t, int, Userspace<sockaddr const*>, socklen_t) override;
- virtual ErrorOr<size_t> recvfrom(OpenFileDescription&, UserOrKernelBuffer&, size_t, int flags, Userspace<sockaddr*>, Userspace<socklen_t*>, Time&, bool blocking) override;
+ virtual ErrorOr<size_t> recvfrom(OpenFileDescription&, UserOrKernelBuffer&, size_t, int flags, Userspace<sockaddr*>, Userspace<socklen_t*>, Duration&, bool blocking) override;
virtual ErrorOr<void> setsockopt(int level, int option, Userspace<void const*>, socklen_t) override;
virtual ErrorOr<void> getsockopt(OpenFileDescription&, int level, int option, Userspace<void*>, Userspace<socklen_t*>) override;
virtual ErrorOr<void> ioctl(OpenFileDescription&, unsigned request, Userspace<void*> arg) override;
- bool did_receive(IPv4Address const& peer_address, u16 peer_port, ReadonlyBytes, Time const&);
+ bool did_receive(IPv4Address const& peer_address, u16 peer_port, ReadonlyBytes, Duration const&);
IPv4Address const& local_address() const { return m_local_address; }
u16 local_port() const { return m_local_port; }
@@ -99,7 +99,7 @@ private:
virtual bool is_ipv4() const override { return true; }
ErrorOr<size_t> receive_byte_buffered(OpenFileDescription&, UserOrKernelBuffer& buffer, size_t buffer_length, int flags, Userspace<sockaddr*>, Userspace<socklen_t*>, bool blocking);
- ErrorOr<size_t> receive_packet_buffered(OpenFileDescription&, UserOrKernelBuffer& buffer, size_t buffer_length, int flags, Userspace<sockaddr*>, Userspace<socklen_t*>, Time&, bool blocking);
+ ErrorOr<size_t> receive_packet_buffered(OpenFileDescription&, UserOrKernelBuffer& buffer, size_t buffer_length, int flags, Userspace<sockaddr*>, Userspace<socklen_t*>, Duration&, bool blocking);
void set_can_read(bool);
@@ -112,7 +112,7 @@ private:
struct ReceivedPacket {
IPv4Address peer_address;
u16 peer_port;
- Time timestamp;
+ Duration timestamp;
OwnPtr<KBuffer> data;
};
diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp
index f5963e8be2..fc625e0c44 100644
--- a/Kernel/Net/LocalSocket.cpp
+++ b/Kernel/Net/LocalSocket.cpp
@@ -333,7 +333,7 @@ DoubleBuffer* LocalSocket::send_buffer_for(OpenFileDescription& description)
return nullptr;
}
-ErrorOr<size_t> LocalSocket::recvfrom(OpenFileDescription& description, UserOrKernelBuffer& buffer, size_t buffer_size, int, Userspace<sockaddr*>, Userspace<socklen_t*>, Time&, bool blocking)
+ErrorOr<size_t> LocalSocket::recvfrom(OpenFileDescription& description, UserOrKernelBuffer& buffer, size_t buffer_size, int, Userspace<sockaddr*>, Userspace<socklen_t*>, Duration&, bool blocking)
{
auto* socket_buffer = receive_buffer_for(description);
if (!socket_buffer)
diff --git a/Kernel/Net/LocalSocket.h b/Kernel/Net/LocalSocket.h
index 25d1716122..a573248b0a 100644
--- a/Kernel/Net/LocalSocket.h
+++ b/Kernel/Net/LocalSocket.h
@@ -47,7 +47,7 @@ public:
virtual bool can_read(OpenFileDescription const&, u64) const override;
virtual bool can_write(OpenFileDescription const&, u64) const override;
virtual ErrorOr<size_t> sendto(OpenFileDescription&, UserOrKernelBuffer const&, size_t, int, Userspace<sockaddr const*>, socklen_t) override;
- virtual ErrorOr<size_t> recvfrom(OpenFileDescription&, UserOrKernelBuffer&, size_t, int flags, Userspace<sockaddr*>, Userspace<socklen_t*>, Time&, bool blocking) override;
+ virtual ErrorOr<size_t> recvfrom(OpenFileDescription&, UserOrKernelBuffer&, size_t, int flags, Userspace<sockaddr*>, Userspace<socklen_t*>, Duration&, bool blocking) override;
virtual ErrorOr<void> getsockopt(OpenFileDescription&, int level, int option, Userspace<void*>, Userspace<socklen_t*>) override;
virtual ErrorOr<void> ioctl(OpenFileDescription&, unsigned request, Userspace<void*> arg) override;
virtual ErrorOr<void> chown(Credentials const&, OpenFileDescription&, UserID, GroupID) override;
diff --git a/Kernel/Net/NetworkAdapter.cpp b/Kernel/Net/NetworkAdapter.cpp
index 9ccfd88d84..3d21995267 100644
--- a/Kernel/Net/NetworkAdapter.cpp
+++ b/Kernel/Net/NetworkAdapter.cpp
@@ -95,7 +95,7 @@ void NetworkAdapter::did_receive(ReadonlyBytes payload)
on_receive();
}
-size_t NetworkAdapter::dequeue_packet(u8* buffer, size_t buffer_size, Time& packet_timestamp)
+size_t NetworkAdapter::dequeue_packet(u8* buffer, size_t buffer_size, Duration& packet_timestamp)
{
InterruptDisabler disabler;
if (m_packet_queue.is_empty())
diff --git a/Kernel/Net/NetworkAdapter.h b/Kernel/Net/NetworkAdapter.h
index 6fd6cabbd3..7549e8d8f0 100644
--- a/Kernel/Net/NetworkAdapter.h
+++ b/Kernel/Net/NetworkAdapter.h
@@ -29,7 +29,7 @@ class NetworkAdapter;
using NetworkByteBuffer = AK::Detail::ByteBuffer<1500>;
struct PacketWithTimestamp final : public AtomicRefCounted<PacketWithTimestamp> {
- PacketWithTimestamp(NonnullOwnPtr<KBuffer> buffer, Time timestamp)
+ PacketWithTimestamp(NonnullOwnPtr<KBuffer> buffer, Duration timestamp)
: buffer(move(buffer))
, timestamp(timestamp)
{
@@ -38,7 +38,7 @@ struct PacketWithTimestamp final : public AtomicRefCounted<PacketWithTimestamp>
ReadonlyBytes bytes() { return buffer->bytes(); }
NonnullOwnPtr<KBuffer> buffer;
- Time timestamp;
+ Duration timestamp;
IntrusiveListNode<PacketWithTimestamp, RefPtr<PacketWithTimestamp>> packet_node;
};
@@ -79,7 +79,7 @@ public:
void send(MACAddress const&, ARPPacket const&);
void fill_in_ipv4_header(PacketWithTimestamp&, IPv4Address const&, MACAddress const&, IPv4Address const&, IPv4Protocol, size_t, u8 type_of_service, u8 ttl);
- size_t dequeue_packet(u8* buffer, size_t buffer_size, Time& packet_timestamp);
+ size_t dequeue_packet(u8* buffer, size_t buffer_size, Duration& packet_timestamp);
bool has_queued_packets() const { return !m_packet_queue.is_empty(); }
diff --git a/Kernel/Net/NetworkTask.cpp b/Kernel/Net/NetworkTask.cpp
index a89860452c..2f6ad1b9bd 100644
--- a/Kernel/Net/NetworkTask.cpp
+++ b/Kernel/Net/NetworkTask.cpp
@@ -26,10 +26,10 @@
namespace Kernel {
static void handle_arp(EthernetFrameHeader const&, size_t frame_size);
-static void handle_ipv4(EthernetFrameHeader const&, size_t frame_size, Time const& packet_timestamp);
-static void handle_icmp(EthernetFrameHeader const&, IPv4Packet const&, Time const& packet_timestamp);
-static void handle_udp(IPv4Packet const&, Time const& packet_timestamp);
-static void handle_tcp(IPv4Packet const&, Time const& packet_timestamp);
+static void handle_ipv4(EthernetFrameHeader const&, size_t frame_size, Duration const& packet_timestamp);
+static void handle_icmp(EthernetFrameHeader const&, IPv4Packet const&, Duration const& packet_timestamp);
+static void handle_udp(IPv4Packet const&, Duration const& packet_timestamp);
+static void handle_tcp(IPv4Packet const&, Duration const& packet_timestamp);
static void send_delayed_tcp_ack(TCPSocket& socket);
static void send_tcp_rst(IPv4Packet const& ipv4_packet, TCPPacket const& tcp_packet, RefPtr<NetworkAdapter> adapter);
static void flush_delayed_tcp_acks();
@@ -74,7 +74,7 @@ void NetworkTask_main(void*)
};
});
- auto dequeue_packet = [&pending_packets](u8* buffer, size_t buffer_size, Time& packet_timestamp) -> size_t {
+ auto dequeue_packet = [&pending_packets](u8* buffer, size_t buffer_size, Duration& packet_timestamp) -> size_t {
if (pending_packets == 0)
return 0;
size_t packet_size = 0;
@@ -94,14 +94,14 @@ void NetworkTask_main(void*)
TODO();
auto buffer_region = region_or_error.release_value();
auto buffer = (u8*)buffer_region->vaddr().get();
- Time packet_timestamp;
+ Duration packet_timestamp;
for (;;) {
flush_delayed_tcp_acks();
retransmit_tcp_packets();
size_t packet_size = dequeue_packet(buffer, buffer_size, packet_timestamp);
if (!packet_size) {
- auto timeout_time = Time::from_milliseconds(500);
+ auto timeout_time = Duration::from_milliseconds(500);
auto timeout = Thread::BlockTimeout { false, &timeout_time };
[[maybe_unused]] auto result = packet_wait_queue.wait_on(timeout, "NetworkTask"sv);
continue;
@@ -177,7 +177,7 @@ void handle_arp(EthernetFrameHeader const& eth, size_t frame_size)
}
}
-void handle_ipv4(EthernetFrameHeader const& eth, size_t frame_size, Time const& packet_timestamp)
+void handle_ipv4(EthernetFrameHeader const& eth, size_t frame_size, Duration const& packet_timestamp)
{
constexpr size_t minimum_ipv4_frame_size = sizeof(EthernetFrameHeader) + sizeof(IPv4Packet);
if (frame_size < minimum_ipv4_frame_size) {
@@ -222,7 +222,7 @@ void handle_ipv4(EthernetFrameHeader const& eth, size_t frame_size, Time const&
}
}
-void handle_icmp(EthernetFrameHeader const& eth, IPv4Packet const& ipv4_packet, Time const& packet_timestamp)
+void handle_icmp(EthernetFrameHeader const& eth, IPv4Packet const& ipv4_packet, Duration const& packet_timestamp)
{
auto& icmp_header = *static_cast<ICMPHeader const*>(ipv4_packet.payload());
dbgln_if(ICMP_DEBUG, "handle_icmp: source={}, destination={}, type={:#02x}, code={:#02x}", ipv4_packet.source().to_string(), ipv4_packet.destination().to_string(), icmp_header.type(), icmp_header.code());
@@ -273,7 +273,7 @@ void handle_icmp(EthernetFrameHeader const& eth, IPv4Packet const& ipv4_packet,
}
}
-void handle_udp(IPv4Packet const& ipv4_packet, Time const& packet_timestamp)
+void handle_udp(IPv4Packet const& ipv4_packet, Duration const& packet_timestamp)
{
if (ipv4_packet.payload_size() < sizeof(UDPPacket)) {
dbgln("handle_udp: Packet too small ({}, need {})", ipv4_packet.payload_size(), sizeof(UDPPacket));
@@ -367,7 +367,7 @@ void send_tcp_rst(IPv4Packet const& ipv4_packet, TCPPacket const& tcp_packet, Re
routing_decision.adapter->release_packet_buffer(*packet);
}
-void handle_tcp(IPv4Packet const& ipv4_packet, Time const& packet_timestamp)
+void handle_tcp(IPv4Packet const& ipv4_packet, Duration const& packet_timestamp)
{
if (ipv4_packet.payload_size() < sizeof(TCPPacket)) {
dbgln("handle_tcp: IPv4 payload is too small to be a TCP packet ({}, need {})", ipv4_packet.payload_size(), sizeof(TCPPacket));
diff --git a/Kernel/Net/Socket.cpp b/Kernel/Net/Socket.cpp
index f5e8357a70..7ecda5b41d 100644
--- a/Kernel/Net/Socket.cpp
+++ b/Kernel/Net/Socket.cpp
@@ -245,7 +245,7 @@ ErrorOr<size_t> Socket::read(OpenFileDescription& description, u64, UserOrKernel
{
if (is_shut_down_for_reading())
return 0;
- Time t {};
+ Duration t {};
return recvfrom(description, buffer, size, 0, {}, 0, t, description.is_blocking());
}
diff --git a/Kernel/Net/Socket.h b/Kernel/Net/Socket.h
index ff071d2d83..ebe42032a8 100644
--- a/Kernel/Net/Socket.h
+++ b/Kernel/Net/Socket.h
@@ -79,7 +79,7 @@ public:
virtual bool is_local() const { return false; }
virtual bool is_ipv4() const { return false; }
virtual ErrorOr<size_t> sendto(OpenFileDescription&, UserOrKernelBuffer const&, size_t, int flags, Userspace<sockaddr const*>, socklen_t) = 0;
- virtual ErrorOr<size_t> recvfrom(OpenFileDescription&, UserOrKernelBuffer&, size_t, int flags, Userspace<sockaddr*>, Userspace<socklen_t*>, Time&, bool blocking) = 0;
+ virtual ErrorOr<size_t> recvfrom(OpenFileDescription&, UserOrKernelBuffer&, size_t, int flags, Userspace<sockaddr*>, Userspace<socklen_t*>, Duration&, bool blocking) = 0;
virtual ErrorOr<void> setsockopt(int level, int option, Userspace<void const*>, socklen_t);
virtual ErrorOr<void> getsockopt(OpenFileDescription&, int level, int option, Userspace<void*>, Userspace<socklen_t*>);
@@ -100,11 +100,11 @@ public:
virtual ErrorOr<struct stat> stat() const override;
virtual ErrorOr<NonnullOwnPtr<KString>> pseudo_path(OpenFileDescription const&) const override = 0;
- bool has_receive_timeout() const { return m_receive_timeout != Time::zero(); }
- Time const& receive_timeout() const { return m_receive_timeout; }
+ bool has_receive_timeout() const { return m_receive_timeout != Duration::zero(); }
+ Duration const& receive_timeout() const { return m_receive_timeout; }
- bool has_send_timeout() const { return m_send_timeout != Time::zero(); }
- Time const& send_timeout() const { return m_send_timeout; }
+ bool has_send_timeout() const { return m_send_timeout != Duration::zero(); }
+ Duration const& send_timeout() const { return m_send_timeout; }
bool wants_timestamp() const { return m_timestamp; }
@@ -173,8 +173,8 @@ private:
SpinlockProtected<RefPtr<NetworkAdapter>, LockRank::None> m_bound_interface;
- Time m_receive_timeout {};
- Time m_send_timeout {};
+ Duration m_receive_timeout {};
+ Duration m_send_timeout {};
int m_timestamp { 0 };
SpinlockProtected<Optional<ErrnoCode>, LockRank::None> m_so_error;
diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp
index 5f1dc365fe..2f86cb7719 100644
--- a/Kernel/Net/TCPSocket.cpp
+++ b/Kernel/Net/TCPSocket.cpp
@@ -354,7 +354,7 @@ bool TCPSocket::should_delay_next_ack() const
return false;
// RFC 1122 says we should not delay ACKs for more than 500 milliseconds.
- if (kgettimeofday() >= m_last_ack_sent_time + Time::from_milliseconds(500))
+ if (kgettimeofday() >= m_last_ack_sent_time + Duration::from_milliseconds(500))
return false;
return true;
@@ -586,7 +586,7 @@ void TCPSocket::retransmit_packets()
for (decltype(m_retransmit_attempts) i = 0; i < m_retransmit_attempts; i++)
retransmit_interval *= 2;
- if (m_last_retransmit_time > now - Time::from_seconds(retransmit_interval))
+ if (m_last_retransmit_time > now - Duration::from_seconds(retransmit_interval))
return;
dbgln_if(TCP_SOCKET_DEBUG, "TCPSocket({}) handling retransmit", this);
diff --git a/Kernel/Net/TCPSocket.h b/Kernel/Net/TCPSocket.h
index a949a0e92b..a110cdf421 100644
--- a/Kernel/Net/TCPSocket.h
+++ b/Kernel/Net/TCPSocket.h
@@ -216,11 +216,11 @@ private:
u32 m_duplicate_acks { 0 };
u32 m_last_ack_number_sent { 0 };
- Time m_last_ack_sent_time;
+ Duration m_last_ack_sent_time;
// FIXME: Make this configurable (sysctl)
static constexpr u32 maximum_retransmits = 5;
- Time m_last_retransmit_time;
+ Duration m_last_retransmit_time;
u32 m_retransmit_attempts { 0 };
// FIXME: Parse window size TCP option from the peer
diff --git a/Kernel/PerformanceManager.h b/Kernel/PerformanceManager.h
index cc41cb9f7f..6de5155739 100644
--- a/Kernel/PerformanceManager.h
+++ b/Kernel/PerformanceManager.h
@@ -164,11 +164,11 @@ public:
static void timer_tick(RegisterState const& regs)
{
- static Time last_wakeup;
+ static Duration last_wakeup;
auto now = kgettimeofday();
- constexpr auto ideal_interval = Time::from_microseconds(1000'000 / OPTIMAL_PROFILE_TICKS_PER_SECOND_RATE);
+ constexpr auto ideal_interval = Duration::from_microseconds(1000'000 / OPTIMAL_PROFILE_TICKS_PER_SECOND_RATE);
auto expected_wakeup = last_wakeup + ideal_interval;
- auto delay = (now > expected_wakeup) ? now - expected_wakeup : Time::from_microseconds(0);
+ auto delay = (now > expected_wakeup) ? now - expected_wakeup : Duration::from_microseconds(0);
last_wakeup = now;
auto* current_thread = Thread::current();
// FIXME: We currently don't collect samples while idle.
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index 5ccb1e370d..a597d7876e 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -635,7 +635,7 @@ ErrorOr<Process::ScopedDescriptionAllocation> Process::OpenFileDescriptions::all
return EMFILE;
}
-Time kgettimeofday()
+Duration kgettimeofday()
{
return TimeManagement::now();
}
diff --git a/Kernel/Process.h b/Kernel/Process.h
index 14b92e5c49..e35fbb0a82 100644
--- a/Kernel/Process.h
+++ b/Kernel/Process.h
@@ -41,7 +41,7 @@
namespace Kernel {
MutexProtected<OwnPtr<KString>>& hostname();
-Time kgettimeofday();
+Duration kgettimeofday();
#define ENUMERATE_PLEDGE_PROMISES \
__ENUMERATE_PLEDGE_PROMISE(stdio) \
diff --git a/Kernel/StdLib.cpp b/Kernel/StdLib.cpp
index 19c7ea30c2..6a984710e9 100644
--- a/Kernel/StdLib.cpp
+++ b/Kernel/StdLib.cpp
@@ -39,28 +39,28 @@ ErrorOr<NonnullOwnPtr<Kernel::KString>> try_copy_kstring_from_user(Userspace<cha
return new_string;
}
-ErrorOr<Time> copy_time_from_user(timespec const* ts_user)
+ErrorOr<Duration> copy_time_from_user(timespec const* ts_user)
{
timespec ts {};
TRY(copy_from_user(&ts, ts_user, sizeof(timespec)));
- return Time::from_timespec(ts);
+ return Duration::from_timespec(ts);
}
-ErrorOr<Time> copy_time_from_user(timeval const* tv_user)
+ErrorOr<Duration> copy_time_from_user(timeval const* tv_user)
{
timeval tv {};
TRY(copy_from_user(&tv, tv_user, sizeof(timeval)));
- return Time::from_timeval(tv);
+ return Duration::from_timeval(tv);
}
template<>
-ErrorOr<Time> copy_time_from_user<timeval const>(Userspace<timeval const*> src) { return copy_time_from_user(src.unsafe_userspace_ptr()); }
+ErrorOr<Duration> copy_time_from_user<timeval const>(Userspace<timeval const*> src) { return copy_time_from_user(src.unsafe_userspace_ptr()); }
template<>
-ErrorOr<Time> copy_time_from_user<timeval>(Userspace<timeval*> src) { return copy_time_from_user(src.unsafe_userspace_ptr()); }
+ErrorOr<Duration> copy_time_from_user<timeval>(Userspace<timeval*> src) { return copy_time_from_user(src.unsafe_userspace_ptr()); }
template<>
-ErrorOr<Time> copy_time_from_user<timespec const>(Userspace<timespec const*> src) { return copy_time_from_user(src.unsafe_userspace_ptr()); }
+ErrorOr<Duration> copy_time_from_user<timespec const>(Userspace<timespec const*> src) { return copy_time_from_user(src.unsafe_userspace_ptr()); }
template<>
-ErrorOr<Time> copy_time_from_user<timespec>(Userspace<timespec*> src) { return copy_time_from_user(src.unsafe_userspace_ptr()); }
+ErrorOr<Duration> copy_time_from_user<timespec>(Userspace<timespec*> src) { return copy_time_from_user(src.unsafe_userspace_ptr()); }
Optional<u32> user_atomic_fetch_add_relaxed(u32 volatile* var, u32 val)
{
diff --git a/Kernel/StdLib.h b/Kernel/StdLib.h
index 09bb646ffd..7cdd2986ea 100644
--- a/Kernel/StdLib.h
+++ b/Kernel/StdLib.h
@@ -15,10 +15,10 @@
#include <Kernel/UnixTypes.h>
ErrorOr<NonnullOwnPtr<Kernel::KString>> try_copy_kstring_from_user(Userspace<char const*>, size_t);
-ErrorOr<Time> copy_time_from_user(timespec const*);
-ErrorOr<Time> copy_time_from_user(timeval const*);
+ErrorOr<Duration> copy_time_from_user(timespec const*);
+ErrorOr<Duration> copy_time_from_user(timeval const*);
template<typename T>
-ErrorOr<Time> copy_time_from_user(Userspace<T*>);
+ErrorOr<Duration> copy_time_from_user(Userspace<T*>);
[[nodiscard]] Optional<u32> user_atomic_fetch_add_relaxed(u32 volatile* var, u32 val);
[[nodiscard]] Optional<u32> user_atomic_exchange_relaxed(u32 volatile* var, u32 val);
diff --git a/Kernel/Storage/NVMe/NVMeController.cpp b/Kernel/Storage/NVMe/NVMeController.cpp
index 89d2dd2e7d..d2753e9af0 100644
--- a/Kernel/Storage/NVMe/NVMeController.cpp
+++ b/Kernel/Storage/NVMe/NVMeController.cpp
@@ -50,7 +50,7 @@ UNMAP_AFTER_INIT ErrorOr<void> NVMeController::initialize(bool is_queue_polled)
m_controller_regs = TRY(Memory::map_typed_writable<ControllerRegister volatile>(PhysicalAddress(m_bar)));
auto caps = m_controller_regs->cap;
- m_ready_timeout = Time::from_milliseconds((CAP_TO(caps) + 1) * 500); // CAP.TO is in 500ms units
+ m_ready_timeout = Duration::from_milliseconds((CAP_TO(caps) + 1) * 500); // CAP.TO is in 500ms units
calculate_doorbell_stride();
// IO queues + 1 admin queue
diff --git a/Kernel/Storage/NVMe/NVMeController.h b/Kernel/Storage/NVMe/NVMeController.h
index 50c8428ec7..072e97aeb7 100644
--- a/Kernel/Storage/NVMe/NVMeController.h
+++ b/Kernel/Storage/NVMe/NVMeController.h
@@ -74,7 +74,7 @@ private:
Memory::TypedMapping<ControllerRegister volatile> m_controller_regs;
bool m_admin_queue_ready { false };
size_t m_device_count { 0 };
- AK::Time m_ready_timeout;
+ AK::Duration m_ready_timeout;
u32 m_bar { 0 };
u8 m_dbl_stride { 0 };
PCI::InterruptType m_irq_type;
diff --git a/Kernel/Syscalls/alarm.cpp b/Kernel/Syscalls/alarm.cpp
index 66ddc5211a..169dd070c8 100644
--- a/Kernel/Syscalls/alarm.cpp
+++ b/Kernel/Syscalls/alarm.cpp
@@ -20,7 +20,7 @@ ErrorOr<FlatPtr> Process::sys$alarm(unsigned seconds)
bool was_in_use = false;
if (TimerQueue::the().cancel_timer(*timer, &was_in_use)) {
// The timer hasn't fired. Round up the remaining time (if any)
- Time remaining = timer->remaining() + Time::from_nanoseconds(999'999'999);
+ Duration remaining = timer->remaining() + Duration::from_nanoseconds(999'999'999);
previous_alarm_remaining = remaining.to_truncated_seconds();
}
// We had an existing alarm, must return a non-zero value here!
@@ -30,7 +30,7 @@ ErrorOr<FlatPtr> Process::sys$alarm(unsigned seconds)
if (seconds > 0) {
auto deadline = TimeManagement::the().current_time(CLOCK_REALTIME_COARSE);
- deadline = deadline + Time::from_seconds(seconds);
+ deadline = deadline + Duration::from_seconds(seconds);
if (!timer) {
timer = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) Timer));
}
diff --git a/Kernel/Syscalls/beep.cpp b/Kernel/Syscalls/beep.cpp
index bc9a4f24b0..7c4f547e17 100644
--- a/Kernel/Syscalls/beep.cpp
+++ b/Kernel/Syscalls/beep.cpp
@@ -21,7 +21,7 @@ ErrorOr<FlatPtr> Process::sys$beep(int tone)
return EINVAL;
#if ARCH(X86_64)
PCSpeaker::tone_on(tone);
- auto result = Thread::current()->sleep(Time::from_nanoseconds(200'000'000));
+ auto result = Thread::current()->sleep(Duration::from_nanoseconds(200'000'000));
PCSpeaker::tone_off();
if (result.was_interrupted())
return EINTR;
diff --git a/Kernel/Syscalls/clock.cpp b/Kernel/Syscalls/clock.cpp
index b8ab20c97f..8d574ab4ea 100644
--- a/Kernel/Syscalls/clock.cpp
+++ b/Kernel/Syscalls/clock.cpp
@@ -82,7 +82,7 @@ ErrorOr<FlatPtr> Process::sys$clock_nanosleep(Userspace<Syscall::SC_clock_nanosl
if (is_absolute) {
was_interrupted = Thread::current()->sleep_until(params.clock_id, requested_sleep).was_interrupted();
} else {
- Time remaining_sleep;
+ Duration remaining_sleep;
was_interrupted = Thread::current()->sleep(params.clock_id, requested_sleep, &remaining_sleep).was_interrupted();
timespec remaining_sleep_ts = remaining_sleep.to_timespec();
if (was_interrupted && params.remaining_sleep) {
@@ -123,7 +123,7 @@ ErrorOr<FlatPtr> Process::sys$adjtime(Userspace<timeval const*> user_delta, User
return EPERM;
auto delta = TRY(copy_time_from_user(user_delta));
- // FIXME: Should use AK::Time internally
+ // FIXME: Should use AK::Duration internally
TimeManagement::the().set_remaining_epoch_time_adjustment(delta.to_timespec());
}
diff --git a/Kernel/Syscalls/resource.cpp b/Kernel/Syscalls/resource.cpp
index b7ab629632..fd3976ebcf 100644
--- a/Kernel/Syscalls/resource.cpp
+++ b/Kernel/Syscalls/resource.cpp
@@ -19,12 +19,12 @@ ErrorOr<FlatPtr> Process::sys$getrusage(int who, Userspace<rusage*> user_usage)
switch (who) {
case RUSAGE_SELF:
- usage.ru_utime = Time::from_ticks(m_ticks_in_user, ticks_per_second).to_timeval();
- usage.ru_stime = Time::from_ticks(m_ticks_in_kernel, ticks_per_second).to_timeval();
+ usage.ru_utime = Duration::from_ticks(m_ticks_in_user, ticks_per_second).to_timeval();
+ usage.ru_stime = Duration::from_ticks(m_ticks_in_kernel, ticks_per_second).to_timeval();
break;
case RUSAGE_CHILDREN:
- usage.ru_utime = Time::from_ticks(m_ticks_in_user_for_dead_children, ticks_per_second).to_timeval();
- usage.ru_stime = Time::from_ticks(m_ticks_in_kernel_for_dead_children, ticks_per_second).to_timeval();
+ usage.ru_utime = Duration::from_ticks(m_ticks_in_user_for_dead_children, ticks_per_second).to_timeval();
+ usage.ru_stime = Duration::from_ticks(m_ticks_in_kernel_for_dead_children, ticks_per_second).to_timeval();
break;
default:
return EINVAL;
diff --git a/Kernel/Syscalls/socket.cpp b/Kernel/Syscalls/socket.cpp
index d7746ab468..10ab6748f6 100644
--- a/Kernel/Syscalls/socket.cpp
+++ b/Kernel/Syscalls/socket.cpp
@@ -272,7 +272,7 @@ ErrorOr<FlatPtr> Process::sys$recvmsg(int sockfd, Userspace<struct msghdr*> user
return 0;
auto data_buffer = TRY(UserOrKernelBuffer::for_user_buffer((u8*)iovs[0].iov_base, iovs[0].iov_len));
- Time timestamp {};
+ Duration timestamp {};
bool blocking = (flags & MSG_DONTWAIT) ? false : description->is_blocking();
auto result = socket.recvfrom(*description, data_buffer, iovs[0].iov_len, flags, user_addr, user_addr_length, timestamp, blocking);
diff --git a/Kernel/Tasks/SyncTask.cpp b/Kernel/Tasks/SyncTask.cpp
index 973cbe5786..b4715a11eb 100644
--- a/Kernel/Tasks/SyncTask.cpp
+++ b/Kernel/Tasks/SyncTask.cpp
@@ -18,7 +18,7 @@ UNMAP_AFTER_INIT void SyncTask::spawn()
dbgln("VFS SyncTask is running");
for (;;) {
VirtualFileSystem::sync();
- (void)Thread::current()->sleep(Time::from_seconds(1));
+ (void)Thread::current()->sleep(Duration::from_seconds(1));
}
}));
}
diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp
index f5df3a1374..d7ab03840b 100644
--- a/Kernel/Thread.cpp
+++ b/Kernel/Thread.cpp
@@ -495,14 +495,14 @@ void Thread::relock_process(LockMode previous_locked, u32 lock_count_to_restore)
}
// NOLINTNEXTLINE(readability-make-member-function-const) False positive; We call block<SleepBlocker> which is not const
-auto Thread::sleep(clockid_t clock_id, Time const& duration, Time* remaining_time) -> BlockResult
+auto Thread::sleep(clockid_t clock_id, Duration const& duration, Duration* remaining_time) -> BlockResult
{
VERIFY(state() == Thread::State::Running);
return Thread::current()->block<Thread::SleepBlocker>({}, Thread::BlockTimeout(false, &duration, nullptr, clock_id), remaining_time);
}
// NOLINTNEXTLINE(readability-make-member-function-const) False positive; We call block<SleepBlocker> which is not const
-auto Thread::sleep_until(clockid_t clock_id, Time const& deadline) -> BlockResult
+auto Thread::sleep_until(clockid_t clock_id, Duration const& deadline) -> BlockResult
{
VERIFY(state() == Thread::State::Running);
return Thread::current()->block<Thread::SleepBlocker>({}, Thread::BlockTimeout(true, &deadline, nullptr, clock_id));
diff --git a/Kernel/Thread.h b/Kernel/Thread.h
index 8e8b9d7d32..a13259e5e6 100644
--- a/Kernel/Thread.h
+++ b/Kernel/Thread.h
@@ -159,16 +159,16 @@ public:
: m_infinite(true)
{
}
- explicit BlockTimeout(bool is_absolute, Time const* time, Time const* start_time = nullptr, clockid_t clock_id = CLOCK_MONOTONIC_COARSE);
+ explicit BlockTimeout(bool is_absolute, Duration const* time, Duration const* start_time = nullptr, clockid_t clock_id = CLOCK_MONOTONIC_COARSE);
- Time const& absolute_time() const { return m_time; }
- Time const* start_time() const { return !m_infinite ? &m_start_time : nullptr; }
+ Duration const& absolute_time() const { return m_time; }
+ Duration const* start_time() const { return !m_infinite ? &m_start_time : nullptr; }
clockid_t clock_id() const { return m_clock_id; }
bool is_infinite() const { return m_infinite; }
private:
- Time m_time {};
- Time m_start_time {};
+ Duration m_time {};
+ Duration m_start_time {};
clockid_t m_clock_id { CLOCK_MONOTONIC_COARSE };
bool m_infinite { false };
};
@@ -559,7 +559,7 @@ public:
class SleepBlocker final : public Blocker {
public:
- explicit SleepBlocker(BlockTimeout const&, Time* = nullptr);
+ explicit SleepBlocker(BlockTimeout const&, Duration* = nullptr);
virtual StringView state_string() const override { return "Sleeping"sv; }
virtual Type blocker_type() const override { return Type::Sleep; }
virtual BlockTimeout const& override_timeout(BlockTimeout const&) override;
@@ -571,7 +571,7 @@ public:
void calculate_remaining();
BlockTimeout m_deadline;
- Time* m_remaining;
+ Duration* m_remaining;
};
class SelectBlocker final : public FileBlocker {
@@ -824,13 +824,13 @@ public:
return block<Thread::WaitQueueBlocker>(timeout, wait_queue, forward<Args>(args)...);
}
- BlockResult sleep(clockid_t, Time const&, Time* = nullptr);
- BlockResult sleep(Time const& duration, Time* remaining_time = nullptr)
+ BlockResult sleep(clockid_t, Duration const&, Duration* = nullptr);
+ BlockResult sleep(Duration const& duration, Duration* remaining_time = nullptr)
{
return sleep(CLOCK_MONOTONIC_COARSE, duration, remaining_time);
}
- BlockResult sleep_until(clockid_t, Time const&);
- BlockResult sleep_until(Time const& duration)
+ BlockResult sleep_until(clockid_t, Duration const&);
+ BlockResult sleep_until(Duration const& duration)
{
return sleep_until(CLOCK_MONOTONIC_COARSE, duration);
}
diff --git a/Kernel/ThreadBlockers.cpp b/Kernel/ThreadBlockers.cpp
index 3035701d04..50e0b8b736 100644
--- a/Kernel/ThreadBlockers.cpp
+++ b/Kernel/ThreadBlockers.cpp
@@ -15,13 +15,13 @@
namespace Kernel {
-Thread::BlockTimeout::BlockTimeout(bool is_absolute, Time const* time, Time const* start_time, clockid_t clock_id)
+Thread::BlockTimeout::BlockTimeout(bool is_absolute, Duration const* time, Duration const* start_time, clockid_t clock_id)
: m_clock_id(clock_id)
, m_infinite(!time)
{
if (m_infinite)
return;
- if (*time > Time::zero())
+ if (*time > Duration::zero())
m_time = *time;
m_start_time = start_time ? *start_time : TimeManagement::the().current_time(clock_id);
if (!is_absolute)
@@ -272,7 +272,7 @@ auto Thread::WriteBlocker::override_timeout(BlockTimeout const& timeout) -> Bloc
if (description.is_socket()) {
auto const& socket = *description.socket();
if (socket.has_send_timeout()) {
- Time send_timeout = socket.send_timeout();
+ Duration send_timeout = socket.send_timeout();
m_timeout = BlockTimeout(false, &send_timeout, timeout.start_time(), timeout.clock_id());
if (timeout.is_infinite() || (!m_timeout.is_infinite() && m_timeout.absolute_time() < timeout.absolute_time()))
return m_timeout;
@@ -292,7 +292,7 @@ auto Thread::ReadBlocker::override_timeout(BlockTimeout const& timeout) -> Block
if (description.is_socket()) {
auto const& socket = *description.socket();
if (socket.has_receive_timeout()) {
- Time receive_timeout = socket.receive_timeout();
+ Duration receive_timeout = socket.receive_timeout();
m_timeout = BlockTimeout(false, &receive_timeout, timeout.start_time(), timeout.clock_id());
if (timeout.is_infinite() || (!m_timeout.is_infinite() && m_timeout.absolute_time() < timeout.absolute_time()))
return m_timeout;
@@ -301,7 +301,7 @@ auto Thread::ReadBlocker::override_timeout(BlockTimeout const& timeout) -> Block
return timeout;
}
-Thread::SleepBlocker::SleepBlocker(BlockTimeout const& deadline, Time* remaining)
+Thread::SleepBlocker::SleepBlocker(BlockTimeout const& deadline, Duration* remaining)
: m_deadline(deadline)
, m_remaining(remaining)
{
diff --git a/Kernel/Time/TimeManagement.cpp b/Kernel/Time/TimeManagement.cpp
index 7dd87343f7..31cb2085b5 100644
--- a/Kernel/Time/TimeManagement.cpp
+++ b/Kernel/Time/TimeManagement.cpp
@@ -77,7 +77,7 @@ ErrorOr<void> TimeManagement::validate_clock_id(clockid_t clock_id)
};
}
-Time TimeManagement::current_time(clockid_t clock_id) const
+Duration TimeManagement::current_time(clockid_t clock_id) const
{
switch (clock_id) {
case CLOCK_MONOTONIC:
@@ -101,15 +101,15 @@ bool TimeManagement::is_system_timer(HardwareTimerBase const& timer) const
return &timer == m_system_timer.ptr();
}
-void TimeManagement::set_epoch_time(Time ts)
+void TimeManagement::set_epoch_time(Duration ts)
{
InterruptDisabler disabler;
- // FIXME: Should use AK::Time internally
+ // FIXME: Should use AK::Duration internally
m_epoch_time = ts.to_timespec();
m_remaining_epoch_time_adjustment = { 0, 0 };
}
-Time TimeManagement::monotonic_time(TimePrecision precision) const
+Duration TimeManagement::monotonic_time(TimePrecision precision) const
{
// This is the time when last updated by an interrupt.
u64 seconds;
@@ -144,10 +144,10 @@ Time TimeManagement::monotonic_time(TimePrecision precision) const
VERIFY(ticks < m_time_ticks_per_second);
u64 ns = ((u64)ticks * 1000000000ull) / m_time_ticks_per_second;
VERIFY(ns < 1000000000ull);
- return Time::from_timespec({ (i64)seconds, (i32)ns });
+ return Duration::from_timespec({ (i64)seconds, (i32)ns });
}
-Time TimeManagement::epoch_time(TimePrecision) const
+Duration TimeManagement::epoch_time(TimePrecision) const
{
// TODO: Take into account precision
timespec ts;
@@ -156,7 +156,7 @@ Time TimeManagement::epoch_time(TimePrecision) const
update_iteration = m_update1.load(AK::MemoryOrder::memory_order_acquire);
ts = m_epoch_time;
} while (update_iteration != m_update2.load(AK::MemoryOrder::memory_order_acquire));
- return Time::from_timespec(ts);
+ return Duration::from_timespec(ts);
}
u64 TimeManagement::uptime_ms() const
@@ -186,14 +186,14 @@ UNMAP_AFTER_INIT void TimeManagement::initialize([[maybe_unused]] u32 cpu)
// would trigger a deadlock trying to get the s_the instance while
// creating it.
if (auto* apic_timer = APIC::the().initialize_timers(*s_the->m_system_timer)) {
- dmesgln("Time: Using APIC timer as system timer");
+ dmesgln("Duration: Using APIC timer as system timer");
s_the->set_system_timer(*apic_timer);
}
}
} else {
VERIFY(s_the.is_initialized());
if (auto* apic_timer = APIC::the().get_timer()) {
- dmesgln("Time: Enable APIC timer on CPU #{}", cpu);
+ dmesgln("Duration: Enable APIC timer on CPU #{}", cpu);
apic_timer->enable_local_timer();
}
}
@@ -226,26 +226,26 @@ time_t TimeManagement::ticks_per_second() const
return m_time_keeper_timer->ticks_per_second();
}
-Time TimeManagement::boot_time()
+Duration TimeManagement::boot_time()
{
#if ARCH(X86_64)
return RTC::boot_time();
#elif ARCH(AARCH64)
// FIXME: Return correct boot time
- return Time::from_seconds(0);
+ return Duration::from_seconds(0);
#else
# error Unknown architecture
#endif
}
-Time TimeManagement::clock_resolution() const
+Duration TimeManagement::clock_resolution() const
{
long nanoseconds_per_tick = 1'000'000'000 / m_time_keeper_timer->ticks_per_second();
- return Time::from_nanoseconds(nanoseconds_per_tick);
+ return Duration::from_nanoseconds(nanoseconds_per_tick);
}
UNMAP_AFTER_INIT TimeManagement::TimeManagement()
- : m_time_page_region(MM.allocate_kernel_region(PAGE_SIZE, "Time page"sv, Memory::Region::Access::ReadWrite, AllocationStrategy::AllocateNow).release_value_but_fixme_should_propagate_errors())
+ : m_time_page_region(MM.allocate_kernel_region(PAGE_SIZE, "Duration page"sv, Memory::Region::Access::ReadWrite, AllocationStrategy::AllocateNow).release_value_but_fixme_should_propagate_errors())
{
#if ARCH(X86_64)
bool probe_non_legacy_hardware_timers = !(kernel_command_line().is_legacy_time_enabled());
@@ -275,7 +275,7 @@ UNMAP_AFTER_INIT TimeManagement::TimeManagement()
#endif
}
-Time TimeManagement::now()
+Duration TimeManagement::now()
{
return s_the.ptr()->epoch_time();
}
@@ -283,7 +283,7 @@ Time TimeManagement::now()
UNMAP_AFTER_INIT Vector<HardwareTimerBase*> TimeManagement::scan_and_initialize_periodic_timers()
{
bool should_enable = is_hpet_periodic_mode_allowed();
- dbgln("Time: Scanning for periodic timers");
+ dbgln("Duration: Scanning for periodic timers");
Vector<HardwareTimerBase*> timers;
for (auto& hardware_timer : m_hardware_timers) {
if (hardware_timer->is_periodic_capable()) {
@@ -297,7 +297,7 @@ UNMAP_AFTER_INIT Vector<HardwareTimerBase*> TimeManagement::scan_and_initialize_
UNMAP_AFTER_INIT Vector<HardwareTimerBase*> TimeManagement::scan_for_non_periodic_timers()
{
- dbgln("Time: Scanning for non-periodic timers");
+ dbgln("Duration: Scanning for non-periodic timers");
Vector<HardwareTimerBase*> timers;
for (auto& hardware_timer : m_hardware_timers) {
if (!hardware_timer->is_periodic_capable())
diff --git a/Kernel/Time/TimeManagement.h b/Kernel/Time/TimeManagement.h
index 4c073614fa..75c161559c 100644
--- a/Kernel/Time/TimeManagement.h
+++ b/Kernel/Time/TimeManagement.h
@@ -41,18 +41,18 @@ public:
static u64 scheduler_current_time();
static ErrorOr<void> validate_clock_id(clockid_t);
- Time current_time(clockid_t) const;
- Time monotonic_time(TimePrecision = TimePrecision::Coarse) const;
- Time monotonic_time_raw() const
+ Duration current_time(clockid_t) const;
+ Duration monotonic_time(TimePrecision = TimePrecision::Coarse) const;
+ Duration monotonic_time_raw() const
{
// TODO: implement
return monotonic_time(TimePrecision::Precise);
}
- Time epoch_time(TimePrecision = TimePrecision::Precise) const;
- void set_epoch_time(Time);
+ Duration epoch_time(TimePrecision = TimePrecision::Precise) const;
+ void set_epoch_time(Duration);
time_t ticks_per_second() const;
- static Time boot_time();
- Time clock_resolution() const;
+ static Duration boot_time();
+ Duration clock_resolution() const;
bool is_system_timer(HardwareTimerBase const&) const;
@@ -64,12 +64,12 @@ public:
bool disable_profile_timer();
u64 uptime_ms() const;
- static Time now();
+ static Duration now();
- // FIXME: Should use AK::Time internally
+ // FIXME: Should use AK::Duration internally
// FIXME: Also, most likely broken, because it does not check m_update[12] for in-progress updates.
timespec remaining_epoch_time_adjustment() const { return m_remaining_epoch_time_adjustment; }
- // FIXME: Should use AK::Time internally
+ // FIXME: Should use AK::Duration internally
// FIXME: Also, most likely broken, because it does not check m_update[12] for in-progress updates.
void set_remaining_epoch_time_adjustment(timespec const& adjustment) { m_remaining_epoch_time_adjustment = adjustment; }
@@ -102,7 +102,7 @@ private:
Atomic<u32> m_update1 { 0 };
u32 m_ticks_this_second { 0 };
u64 m_seconds_since_boot { 0 };
- // FIXME: Should use AK::Time internally
+ // FIXME: Should use AK::Duration internally
timespec m_epoch_time { 0, 0 };
timespec m_remaining_epoch_time_adjustment { 0, 0 };
Atomic<u32> m_update2 { 0 };
diff --git a/Kernel/TimerQueue.cpp b/Kernel/TimerQueue.cpp
index bcb7001e74..599ecf6248 100644
--- a/Kernel/TimerQueue.cpp
+++ b/Kernel/TimerQueue.cpp
@@ -16,12 +16,12 @@ namespace Kernel {
static Singleton<TimerQueue> s_the;
static Spinlock<LockRank::None> g_timerqueue_lock {};
-Time Timer::remaining() const
+Duration Timer::remaining() const
{
return m_remaining;
}
-Time Timer::now(bool is_firing) const
+Duration Timer::now(bool is_firing) const
{
// NOTE: If is_firing is true then TimePrecision::Precise isn't really useful here.
// We already have a quite precise time stamp because we just updated the time in the
@@ -55,7 +55,7 @@ UNMAP_AFTER_INIT TimerQueue::TimerQueue()
m_ticks_per_second = TimeManagement::the().ticks_per_second();
}
-bool TimerQueue::add_timer_without_id(NonnullRefPtr<Timer> timer, clockid_t clock_id, Time const& deadline, Function<void()>&& callback)
+bool TimerQueue::add_timer_without_id(NonnullRefPtr<Timer> timer, clockid_t clock_id, Duration const& deadline, Function<void()>&& callback)
{
if (deadline <= TimeManagement::the().current_time(clock_id))
return false;
@@ -86,7 +86,7 @@ TimerId TimerQueue::add_timer(NonnullRefPtr<Timer>&& timer)
void TimerQueue::add_timer_locked(NonnullRefPtr<Timer> timer)
{
- Time timer_expiration = timer->m_expires;
+ Duration timer_expiration = timer->m_expires;
timer->clear_cancelled();
timer->clear_callback_finished();
diff --git a/Kernel/TimerQueue.h b/Kernel/TimerQueue.h
index 049f95b1da..7258c33eca 100644
--- a/Kernel/TimerQueue.h
+++ b/Kernel/TimerQueue.h
@@ -22,7 +22,7 @@ class Timer final : public AtomicRefCounted<Timer> {
friend class TimerQueue;
public:
- void setup(clockid_t clock_id, Time expires, Function<void()>&& callback)
+ void setup(clockid_t clock_id, Duration expires, Function<void()>&& callback)
{
VERIFY(!is_queued());
m_clock_id = clock_id;
@@ -35,13 +35,13 @@ public:
VERIFY(!is_queued());
}
- Time remaining() const;
+ Duration remaining() const;
private:
TimerId m_id;
clockid_t m_clock_id;
- Time m_expires;
- Time m_remaining {};
+ Duration m_expires;
+ Duration m_remaining {};
Function<void()> m_callback;
Atomic<bool> m_cancelled { false };
Atomic<bool> m_callback_finished { false };
@@ -71,7 +71,7 @@ private:
void clear_callback_finished() { m_callback_finished.store(false, AK::memory_order_release); }
void set_callback_finished() { m_callback_finished.store(true, AK::memory_order_release); }
- Time now(bool) const;
+ Duration now(bool) const;
bool is_queued() const { return m_list_node.is_in_list(); }
@@ -88,14 +88,14 @@ public:
static TimerQueue& the();
TimerId add_timer(NonnullRefPtr<Timer>&&);
- bool add_timer_without_id(NonnullRefPtr<Timer>, clockid_t, Time const&, Function<void()>&&);
+ bool add_timer_without_id(NonnullRefPtr<Timer>, clockid_t, Duration const&, Function<void()>&&);
bool cancel_timer(Timer& timer, bool* was_in_use = nullptr);
void fire();
private:
struct Queue {
Timer::List list;
- Time next_timer_due {};
+ Duration next_timer_due {};
};
void remove_timer_locked(Queue&, Timer&);
void update_next_timer_due(Queue&);