Internal change

PiperOrigin-RevId: 361877303
This commit is contained in:
hai007
2021-03-09 12:55:53 -08:00
committed by Copybara-Service
parent 8fafd3ef09
commit b3d4ac6ffc
13 changed files with 403 additions and 15 deletions
@@ -175,5 +175,32 @@ TEST(ScheduledExecutorTest,
EXPECT_EQ(value, 1);
}
struct ThreadCheckTestClass {
ScheduledExecutor executor;
int value ABSL_GUARDED_BY(executor) = 0;
void incValue() ABSL_EXCLUSIVE_LOCKS_REQUIRED(executor) { value++; }
int getValue() ABSL_EXCLUSIVE_LOCKS_REQUIRED(executor) { return value; }
};
TEST(ScheduledExecutorTest, ThreadCheck_Execute) {
ThreadCheckTestClass test_class;
test_class.executor.Execute(
[&test_class]() ABSL_EXCLUSIVE_LOCKS_REQUIRED(test_class.executor) {
test_class.incValue();
});
}
TEST(ScheduledExecutorTest, ThreadCheck_Schedule) {
ThreadCheckTestClass test_class;
test_class.executor.Schedule(
[&test_class]() ABSL_EXCLUSIVE_LOCKS_REQUIRED(test_class.executor) {
test_class.incValue();
},
absl::ZeroDuration());
}
} // namespace nearby
} // namespace location