}
}
-Future<Unit> SingletonVault::doEagerInitVia(Executor* exe) {
+void SingletonVault::doEagerInitVia(Executor* exe) {
std::unordered_set<detail::SingletonHolderBase*> singletonSet;
{
RWSpinLock::ReadHolder rh(&stateMutex_);
singletonSet = eagerInitSingletons_; // copy set of pointers
}
- std::vector<Future<Unit>> resultFutures;
for (auto* single : singletonSet) {
- resultFutures.emplace_back(via(exe).then([single] {
+ exe->add([single] {
if (!single->creationStarted()) {
single->createInstance();
}
- }));
+ });
}
-
- return collectAll(resultFutures).via(exe).then();
}
void SingletonVault::destroyInstances() {
#include <folly/RWSpinLock.h>
#include <folly/Demangle.h>
#include <folly/Executor.h>
-#include <folly/futures/Future.h>
#include <folly/io/async/Request.h>
#include <algorithm>
/**
* Schedule eager singletons' initializations through the given executor.
- * Return a future which is fulfilled after all the initialization functions
- * complete.
*/
- Future<Unit> doEagerInitVia(Executor* exe);
+ void doEagerInitVia(Executor* exe);
// Destroy all singletons; when complete, the vault can't create
// singletons once again until reenableInstances() is called.
folly::EventBase eb;
vault.registrationComplete();
EXPECT_FALSE(didEagerInit);
- auto result = vault.doEagerInitVia(&eb); // a Future<Unit> is returned
+ vault.doEagerInitVia(&eb);
eb.loop();
- result.get(); // ensure this completed successfully and didn't hang forever
EXPECT_TRUE(didEagerInit);
sing.get_weak(); // (avoid compile error complaining about unused var 'sing')
}
for (size_t j = 0; j < kThreads; j++) {
threads.push_back(std::make_shared<std::thread>([&] {
barrier.wait();
- vault.doEagerInitVia(&exe).get();
+ vault.doEagerInitVia(&exe);
}));
}