mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:07:45 +00:00
Kernel: Add Processor::try_for_each() for fallible iteration
This API will allow users to short circuit iteration and properly propagate errors.
This commit is contained in:
parent
9da8c78133
commit
f4875b9967
1 changed files with 11 additions and 0 deletions
|
@ -208,6 +208,17 @@ public:
|
||||||
return IterationDecision::Continue;
|
return IterationDecision::Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline ErrorOr<void> try_for_each(Function<ErrorOr<void>(Processor&)> callback)
|
||||||
|
{
|
||||||
|
auto& procs = processors();
|
||||||
|
size_t count = procs.size();
|
||||||
|
for (size_t i = 0; i < count; i++) {
|
||||||
|
if (procs[i] != nullptr)
|
||||||
|
TRY(callback(*procs[i]));
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
ALWAYS_INLINE u8 physical_address_bit_width() const { return m_physical_address_bit_width; }
|
ALWAYS_INLINE u8 physical_address_bit_width() const { return m_physical_address_bit_width; }
|
||||||
ALWAYS_INLINE u8 virtual_address_bit_width() const { return m_virtual_address_bit_width; }
|
ALWAYS_INLINE u8 virtual_address_bit_width() const { return m_virtual_address_bit_width; }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue