mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
df74a9222f
The scheduler expects m_select_timeout to act as a deadline. That is, it should contain the time that a task should wake at -- but we were directly copying the time from userspace, which meant that it always returned virtually immediately. At the same time, fix CEventLoop to not rely on the broken select behavior by subtracting the current time from the time of the nearest timer.
25 lines
624 B
C++
25 lines
624 B
C++
#pragma once
|
|
|
|
namespace AK {
|
|
|
|
inline void timeval_sub(const struct timeval* a, const struct timeval* b, struct timeval* result)
|
|
{
|
|
result->tv_sec = a->tv_sec - b->tv_sec;
|
|
result->tv_usec = a->tv_usec - b->tv_usec;
|
|
if (result->tv_usec < 0) {
|
|
--result->tv_sec;
|
|
result->tv_usec += 1000000;
|
|
}
|
|
}
|
|
|
|
inline void timeval_add(const struct timeval* a, const struct timeval* b, struct timeval* result)
|
|
{
|
|
result->tv_sec = a->tv_sec + b->tv_sec;
|
|
result->tv_usec = a->tv_usec + b->tv_usec;
|
|
if (result->tv_usec > 1000000) {
|
|
++result->tv_sec;
|
|
result->tv_usec -= 1000000;
|
|
}
|
|
}
|
|
|
|
}
|