[PATCH] Speculatively instantiate archive members
Simon Atanasyan
simon at atanasyan.com
Fri Jan 16 08:27:32 PST 2015
================
Comment at: lib/ReaderWriter/FileArchive.cpp:102
@@ +101,3 @@
+ group.spawn([this, promise, ci, &group] {
+ std::unique_ptr<File> result;
+ if (instantiateMember(ci, result)) {
----------------
It looks like we can remove the `group` from the capture list because it is not used in the lambda body.
================
Comment at: lib/ReaderWriter/FileArchive.cpp:274
@@ +273,3 @@
+ mutable std::map<const char *, std::future<const File *>> _preloaded;
+ mutable std::vector<std::unique_ptr<std::promise<const File *>>> _promises;
+ mutable std::mutex _mutex;
----------------
Can we store promises directly and do not use `unique_ptr` wrapper? Though I did not test the following code, it compiled successfully. Does it have a sense?
```
// Instantiate the member
_promises.emplace_back();
auto &promise = _promises.back();
_preloaded[memberStart] = promise.get_future();
group.spawn([this, &promise, ci] {
std::unique_ptr<File> result;
if (instantiateMember(ci, result)) {
promise.set_value(nullptr);
return;
}
promise.set_value(result.release());
});
[...]
mutable std::vector<std::promise<const File *>> _promises;
```
http://reviews.llvm.org/D7015
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list