EXPECT_TRUE(f.a);
}
+#ifndef __APPLE__ // TODO #7372389
/// Simple executor that does work in another thread
class ThreadExecutor : public Executor {
folly::MPMCQueue<Func> funcs;
EXPECT_EQ(42, *val);
}
+TEST(Via, callbackRace) {
+ ThreadExecutor x;
+
+ auto fn = [&x]{
+ auto promises = std::make_shared<std::vector<Promise<void>>>(4);
+ std::vector<Future<void>> futures;
+
+ for (auto& p : *promises) {
+ futures.emplace_back(
+ p.getFuture()
+ .via(&x)
+ .then([](Try<void>&&){}));
+ }
+
+ x.waitForStartup();
+ x.add([promises]{
+ for (auto& p : *promises) {
+ p.setValue();
+ }
+ });
+
+ return collectAll(futures);
+ };
+
+ fn().wait();
+}
+#endif
+
class DummyDrivableExecutor : public DrivableExecutor {
public:
void add(Func f) override {}
t2.join();
}
-TEST(Via, callbackRace) {
- ThreadExecutor x;
-
- auto fn = [&x]{
- auto promises = std::make_shared<std::vector<Promise<void>>>(4);
- std::vector<Future<void>> futures;
-
- for (auto& p : *promises) {
- futures.emplace_back(
- p.getFuture()
- .via(&x)
- .then([](Try<void>&&){}));
- }
-
- x.waitForStartup();
- x.add([promises]{
- for (auto& p : *promises) {
- p.setValue();
- }
- });
-
- return collectAll(futures);
- };
-
- fn().wait();
-}
-
TEST(ViaFunc, liftsVoid) {
ManualExecutor x;
int count = 0;