mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 10:01:13 +09:00
Kernel: Add OpenFileDescriptions::try_enumerate for fallible iteration
This API will allow users to short circuit iteration and properly propagate errors.
This commit is contained in:
parent
aca6c0c031
commit
064b93c2ad
Notes:
sideshowbarker
2024-07-18 22:57:59 +09:00
Author: https://github.com/IdanHo
Commit: 064b93c2ad
Pull-request: https://github.com/SerenityOS/serenity/pull/12754
Reviewed-by: https://github.com/bgianfo ✅
Reviewed-by: https://github.com/elcuco
2 changed files with 9 additions and 0 deletions
|
@ -446,6 +446,14 @@ void Process::OpenFileDescriptions::enumerate(Function<void(const OpenFileDescri
|
|||
}
|
||||
}
|
||||
|
||||
ErrorOr<void> Process::OpenFileDescriptions::try_enumerate(Function<ErrorOr<void>(const OpenFileDescriptionAndFlags&)> callback) const
|
||||
{
|
||||
for (auto const& file_description_metadata : m_fds_metadatas) {
|
||||
TRY(callback(file_description_metadata));
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
void Process::OpenFileDescriptions::change_each(Function<void(OpenFileDescriptionAndFlags&)> callback)
|
||||
{
|
||||
for (auto& file_description_metadata : m_fds_metadatas) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue