Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/Thread.cpp

Issue 10105002: Add Sleep and Lock utilities (Closed)
Patch Set: Created April 4, 2013, 5:34 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/Thread.h ('k') | test/Thread.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/Thread.cpp
===================================================================
--- a/src/Thread.cpp
+++ b/src/Thread.cpp
@@ -1,3 +1,7 @@
+#ifndef WIN32
+#include <unistd.h>
+#endif
+
#include "Thread.h"
using namespace AdblockPlus;
@@ -10,6 +14,15 @@
}
}
+void AdblockPlus::Sleep(const int millis)
+{
+#ifdef WIN32
+ ::Sleep(millis);
+#else
+ usleep(millis * 1000);
+#endif
+}
+
Mutex::Mutex()
{
#ifdef WIN32
@@ -46,6 +59,16 @@
#endif
}
+Lock::Lock(Mutex& mutex) : mutex(mutex)
+{
+ mutex.Lock();
+}
+
+Lock::~Lock()
+{
+ mutex.Unlock();
+}
+
ConditionVariable::ConditionVariable()
{
#ifdef WIN32
« no previous file with comments | « src/Thread.h ('k') | test/Thread.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld