Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1399)

Unified Diff: util/synchronization/semaphore_test.cc

Issue 909263002: Add Semaphore::TimedWait() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: util/synchronization/semaphore_test.cc
diff --git a/util/synchronization/semaphore_test.cc b/util/synchronization/semaphore_test.cc
index 7046373936132d1b012c7742d584beb88b15854a..f359cbddceebf406909fb6d072538afc0fa30ab2 100644
--- a/util/synchronization/semaphore_test.cc
+++ b/util/synchronization/semaphore_test.cc
@@ -30,6 +30,17 @@ TEST(Semaphore, Simple) {
semaphore.Signal();
}
+TEST(Semaphore, TimedWait) {
+ Semaphore semaphore(0);
+ semaphore.Signal();
+ EXPECT_TRUE(semaphore.TimedWait(0.01)); // 10ms
+}
+
+TEST(Semaphore, TimedWaitTimeout) {
+ Semaphore semaphore(0);
+ EXPECT_FALSE(semaphore.TimedWait(0.01)); // 10ms
+}
+
struct ThreadMainInfo {
#if defined(OS_POSIX)
pthread_t pthread;

Powered by Google App Engine
This is Rietveld 408576698