mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-07 02:42:52 +00:00
Previously RS handled all the requests in an event loop, leading to issues with connections being started in the middle of other connections being started (and potentially blowing up the stack), ultimately causing requests to be delayed because of other requests. This commit reworks the way we handle these (specifically starting connections) by first serialising the requests, and then performing them in multiple threads concurrently; which yields a significant loading performance and reliability increase.
43 lines
877 B
C++
43 lines
877 B
C++
/*
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <AK/Assertions.h>
|
|
#include <AK/Time.h>
|
|
#include <LibCore/ElapsedTimer.h>
|
|
|
|
namespace Core {
|
|
|
|
ElapsedTimer ElapsedTimer::start_new(TimerType timer_type)
|
|
{
|
|
ElapsedTimer timer(timer_type);
|
|
timer.start();
|
|
return timer;
|
|
}
|
|
|
|
void ElapsedTimer::start()
|
|
{
|
|
m_valid = true;
|
|
m_origin_time = m_timer_type == TimerType::Precise ? MonotonicTime::now() : MonotonicTime::now_coarse();
|
|
}
|
|
|
|
void ElapsedTimer::reset()
|
|
{
|
|
m_valid = false;
|
|
}
|
|
|
|
i64 ElapsedTimer::elapsed_milliseconds() const
|
|
{
|
|
return elapsed_time().to_milliseconds();
|
|
}
|
|
|
|
Duration ElapsedTimer::elapsed_time() const
|
|
{
|
|
VERIFY(is_valid());
|
|
auto now = m_timer_type == TimerType::Precise ? MonotonicTime::now() : MonotonicTime::now_coarse();
|
|
return now - m_origin_time;
|
|
}
|
|
|
|
}
|