mirror of
https://github.com/SerenityOS/serenity
synced 2026-05-05 06:32:26 +02:00
Previously, you'd occasionally see this sort of construct (simplified):
```
return FooDevice::all_instances().with([&](auto& list) {
for (auto& device : list) {
if (/* search condition */)
continue;
return do_something_that_reacquires(device.index());
}
return ENOENT;
});
```
This would only work if the relevant `all_instances()` used a recursive
spinlock, since reacquiring the device would lock that again.
To get around this, a new helper has been added in `Device` through
which devices can be accessed whilst locking the device list, removing
the need to loop through the device type's `all_instances()`.
51 KiB
51 KiB