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

Unified Diff: src/base/platform/semaphore.cc

Issue 521473003: More PNaCL fixes (without GYP/Makefile tweaks) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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
« no previous file with comments | « src/base/platform/platform-posix.cc ('k') | src/base/sys-info.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/base/platform/semaphore.cc
diff --git a/src/base/platform/semaphore.cc b/src/base/platform/semaphore.cc
index e11338fd55a4a37698ab56a91592534a7d5a0fe6..669240e6088cc8093ed3ab5c89b24645421d13bb 100644
--- a/src/base/platform/semaphore.cc
+++ b/src/base/platform/semaphore.cc
@@ -12,6 +12,7 @@
#include <errno.h>
#include "src/base/logging.h"
+#include "src/base/platform/elapsed-timer.h"
#include "src/base/platform/time.h"
namespace v8 {
@@ -106,6 +107,17 @@ void Semaphore::Wait() {
bool Semaphore::WaitFor(const TimeDelta& rel_time) {
+#if V8_OS_NACL
+ // PNaCL doesn't support sem_timedwait, do ugly busy waiting.
+ ElapsedTimer timer;
+ timer.Start();
+ do {
+ int result = sem_trywait(&native_handle_);
+ if (result == 0) return true;
+ DCHECK(errno == EAGAIN || error == EINTR);
+ } while (!timer.HasExpired(rel_time));
+ return false;
+#else
// Compute the time for end of timeout.
const Time time = Time::NowFromSystemTime() + rel_time;
const struct timespec ts = time.ToTimespec();
@@ -129,6 +141,7 @@ bool Semaphore::WaitFor(const TimeDelta& rel_time) {
DCHECK_EQ(-1, result);
DCHECK_EQ(EINTR, errno);
}
+#endif
}
#elif V8_OS_WIN
« no previous file with comments | « src/base/platform/platform-posix.cc ('k') | src/base/sys-info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698