mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 20:29:18 +00:00
LibCore: Add System::sleep_ms
This commit is contained in:
parent
e6e233fd64
commit
a291a7f770
Notes:
github-actions[bot]
2025-02-06 22:17:55 +00:00
Author: https://github.com/stasoid
Commit: a291a7f770
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2917
Reviewed-by: https://github.com/ADKaster ✅
3 changed files with 14 additions and 0 deletions
|
@ -1010,4 +1010,11 @@ bool is_socket(int fd)
|
||||||
return !result.is_error() && S_ISSOCK(result.value().st_mode);
|
return !result.is_error() && S_ISSOCK(result.value().st_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorOr<void> sleep_ms(u32 milliseconds)
|
||||||
|
{
|
||||||
|
if (usleep(1000 * milliseconds) != 0)
|
||||||
|
return Error::from_syscall("usleep"sv, -errno);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,5 +181,6 @@ ErrorOr<void> set_resource_limits(int resource, rlim_t limit);
|
||||||
|
|
||||||
int getpid();
|
int getpid();
|
||||||
bool is_socket(int fd);
|
bool is_socket(int fd);
|
||||||
|
ErrorOr<void> sleep_ms(u32 milliseconds);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,4 +225,10 @@ bool is_socket(int handle)
|
||||||
return GetFileType(to_handle(handle)) == FILE_TYPE_PIPE;
|
return GetFileType(to_handle(handle)) == FILE_TYPE_PIPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ErrorOr<void> sleep_ms(u32 milliseconds)
|
||||||
|
{
|
||||||
|
Sleep(milliseconds);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue