LibCore: Prefix AK::Duration with AK Namespace

This commit is contained in:
Andrew Kaster 2024-07-16 23:43:39 -06:00 committed by Sam Atkins
parent 6772d442e5
commit 383c15b22e
Notes: sideshowbarker 2024-07-18 23:46:56 +09:00
6 changed files with 16 additions and 16 deletions

View file

@ -33,7 +33,7 @@ i64 ElapsedTimer::elapsed_milliseconds() const
return elapsed_time().to_milliseconds();
}
Duration ElapsedTimer::elapsed_time() const
AK::Duration ElapsedTimer::elapsed_time() const
{
VERIFY(is_valid());
auto now = m_timer_type == TimerType::Precise ? MonotonicTime::now() : MonotonicTime::now_coarse();

View file

@ -29,7 +29,7 @@ public:
void reset();
i64 elapsed_milliseconds() const;
Duration elapsed_time() const;
AK::Duration elapsed_time() const;
// FIXME: Move callers to elapsed_milliseconds(), remove this.
i64 elapsed() const // milliseconds

View file

@ -71,7 +71,7 @@ public:
protected:
union {
Duration m_duration;
AK::Duration m_duration;
MonotonicTime m_fire_time;
};
@ -209,7 +209,7 @@ public:
ThreadEventQueue::current().post_event(*strong_owner, make<TimerEvent>());
}
Duration interval;
AK::Duration interval;
bool should_reload { false };
TimerShouldFireWhenNotVisible fire_when_not_visible { TimerShouldFireWhenNotVisible::No };
WeakPtr<EventReceiver> owner;
@ -367,7 +367,7 @@ retry:
if (next_timer_expiration.has_value()) {
auto computed_timeout = next_timer_expiration.value() - time_at_iteration_start;
if (computed_timeout.is_negative())
computed_timeout = Duration::zero();
computed_timeout = AK::Duration::zero();
i64 true_timeout = computed_timeout.to_milliseconds();
timeout = static_cast<i32>(min<i64>(AK::NumericLimits<i32>::max(), true_timeout));
} else {
@ -651,7 +651,7 @@ intptr_t EventLoopManagerUnix::register_timer(EventReceiver& object, int millise
auto timer = new EventLoopTimer;
timer->owner_thread = s_thread_id;
timer->owner = object;
timer->interval = Duration::from_milliseconds(milliseconds);
timer->interval = AK::Duration::from_milliseconds(milliseconds);
timer->reload(MonotonicTime::now_coarse());
timer->should_reload = should_reload;
timer->fire_when_not_visible = fire_when_not_visible;

View file

@ -61,15 +61,15 @@ ErrorOr<void> update_process_statistics(ProcessStatistics& statistics)
}
timeval scratch_timeval = { static_cast<time_t>(time_info.user_time.seconds), static_cast<suseconds_t>(time_info.user_time.microseconds) };
auto time_in_process = Duration::from_timeval(scratch_timeval);
auto time_in_process = AK::Duration::from_timeval(scratch_timeval);
scratch_timeval = { static_cast<time_t>(time_info.system_time.seconds), static_cast<suseconds_t>(time_info.system_time.microseconds) };
time_in_process += Duration::from_timeval(scratch_timeval);
time_in_process += AK::Duration::from_timeval(scratch_timeval);
auto time_diff_process = time_in_process - Duration::from_microseconds(process->time_spent_in_process);
auto time_diff_process = time_in_process - AK::Duration::from_microseconds(process->time_spent_in_process);
process->time_spent_in_process = time_in_process.to_microseconds();
process->cpu_percent = 0.0f;
if (time_diff_process > Duration::zero())
if (time_diff_process > AK::Duration::zero())
process->cpu_percent = 100.0f * static_cast<float>(time_diff_process.to_microseconds()) / total_cpu_micro_diff;
}

View file

@ -200,7 +200,7 @@ ErrorOr<void> PosixSocketHelper::set_close_on_exec(bool enabled)
return {};
}
ErrorOr<void> PosixSocketHelper::set_receive_timeout(Duration timeout)
ErrorOr<void> PosixSocketHelper::set_receive_timeout(AK::Duration timeout)
{
auto timeout_spec = timeout.to_timespec();
return System::setsockopt(m_fd, SOL_SOCKET, SO_RCVTIMEO, &timeout_spec, sizeof(timeout_spec));
@ -259,14 +259,14 @@ ErrorOr<size_t> PosixSocketHelper::pending_bytes() const
return static_cast<size_t>(value);
}
ErrorOr<NonnullOwnPtr<UDPSocket>> UDPSocket::connect(ByteString const& host, u16 port, Optional<Duration> timeout)
ErrorOr<NonnullOwnPtr<UDPSocket>> UDPSocket::connect(ByteString const& host, u16 port, Optional<AK::Duration> timeout)
{
auto ip_address = TRY(resolve_host(host, SocketType::Datagram));
return ip_address.visit([port, timeout](auto address) { return connect(SocketAddress { address, port }, timeout); });
}
ErrorOr<NonnullOwnPtr<UDPSocket>> UDPSocket::connect(SocketAddress const& address, Optional<Duration> timeout)
ErrorOr<NonnullOwnPtr<UDPSocket>> UDPSocket::connect(SocketAddress const& address, Optional<AK::Duration> timeout)
{
auto socket = TRY(adopt_nonnull_own_or_enomem(new (nothrow) UDPSocket()));

View file

@ -144,7 +144,7 @@ public:
ErrorOr<void> set_blocking(bool enabled);
ErrorOr<void> set_close_on_exec(bool enabled);
ErrorOr<void> set_receive_timeout(Duration timeout);
ErrorOr<void> set_receive_timeout(AK::Duration timeout);
void setup_notifier();
RefPtr<Core::Notifier> notifier() { return m_notifier; }
@ -218,8 +218,8 @@ private:
class UDPSocket final : public Socket {
public:
static ErrorOr<NonnullOwnPtr<UDPSocket>> connect(ByteString const& host, u16 port, Optional<Duration> timeout = {});
static ErrorOr<NonnullOwnPtr<UDPSocket>> connect(SocketAddress const& address, Optional<Duration> timeout = {});
static ErrorOr<NonnullOwnPtr<UDPSocket>> connect(ByteString const& host, u16 port, Optional<AK::Duration> timeout = {});
static ErrorOr<NonnullOwnPtr<UDPSocket>> connect(SocketAddress const& address, Optional<AK::Duration> timeout = {});
UDPSocket(UDPSocket&& other)
: Socket(static_cast<Socket&&>(other))