JDevlieghere wrote:
Your suggestion to use `GetSnapshot` and `std::optional` made me realize that
there's an easier way to achieve this, with less locking. It also made me
realize that the whole `GetFooAtIndex` thing isn't really resilient against
plugins coming and going while you're iterating over that.
If we double down on taking snapshots, we could get rid of this pattern and
instead return a snapshot of callbacks. So we could replace patterns like
```
ObjectContainerCreateInstance callback;
for (uint32_t idx = 0;
(callback = PluginManager::GetObjectContainerCreateCallbackAtIndex(
idx)) != nullptr;
++idx) {
// Call callback();
}
```
with something like
```
for (ObjectContainerCreateInstance callback :
PluginManager::GetObjectContainerCreateCallbacks()) {
// Call callback();
}
```
https://github.com/llvm/llvm-project/pull/184452
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits