summaryrefslogtreecommitdiffstats
path: root/base/platform_thread.cc
diff options
context:
space:
mode:
Diffstat (limited to 'base/platform_thread.cc')
-rw-r--r--base/platform_thread.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/base/platform_thread.cc b/base/platform_thread.cc
index 1966ab2..3cb8f39 100644
--- a/base/platform_thread.cc
+++ b/base/platform_thread.cc
@@ -27,6 +27,10 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#ifndef WIN32
+#include <sched.h>
+#endif
+
#include "base/platform_thread.h"
// static
@@ -42,6 +46,15 @@ PlatformThread PlatformThread::Current() {
return thread;
}
+// static
+void PlatformThread::YieldCurrentThread() {
+#ifdef WIN32
+ ::Sleep(0);
+#else
+ sched_yield();
+#endif
+}
+
bool PlatformThread::operator==(const PlatformThread& other_thread) {
#ifdef WIN32
return thread_ == other_thread.thread_;