mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 03:25:13 +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: https://github.com/LadybirdBrowser/ladybird/commit/a291a7f7706 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);
|
||||
}
|
||||
|
||||
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();
|
||||
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;
|
||||
}
|
||||
|
||||
ErrorOr<void> sleep_ms(u32 milliseconds)
|
||||
{
|
||||
Sleep(milliseconds);
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue