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

Side by Side Diff: base/threading/platform_thread_posix.cc

Issue 9703053: Remove old Sleep and PostDelayedTask interfaces that use int ms instead of TimeDelta. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove old PDT interface in webkit/dom_storage. Created 8 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/threading/platform_thread.h" 5 #include "base/threading/platform_thread.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <sched.h> 8 #include <sched.h>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 return reinterpret_cast<int64>(pthread_self()); 145 return reinterpret_cast<int64>(pthread_self());
146 #endif 146 #endif
147 } 147 }
148 148
149 // static 149 // static
150 void PlatformThread::YieldCurrentThread() { 150 void PlatformThread::YieldCurrentThread() {
151 sched_yield(); 151 sched_yield();
152 } 152 }
153 153
154 // static 154 // static
155 void PlatformThread::Sleep(int duration_ms) {
156 // NOTE: This function will be supplanted by the other version of Sleep
157 // in the future. See issue 108171 for more information.
158 Sleep(TimeDelta::FromMilliseconds(duration_ms));
159 }
160
161 // static
162 void PlatformThread::Sleep(TimeDelta duration) { 155 void PlatformThread::Sleep(TimeDelta duration) {
163 struct timespec sleep_time, remaining; 156 struct timespec sleep_time, remaining;
164 157
165 // Break the duration into seconds and nanoseconds. 158 // Break the duration into seconds and nanoseconds.
166 // NOTE: TimeDelta's microseconds are int64s while timespec's 159 // NOTE: TimeDelta's microseconds are int64s while timespec's
167 // nanoseconds are longs, so this unpacking must prevent overflow. 160 // nanoseconds are longs, so this unpacking must prevent overflow.
168 sleep_time.tv_sec = duration.InSeconds(); 161 sleep_time.tv_sec = duration.InSeconds();
169 duration -= TimeDelta::FromSeconds(sleep_time.tv_sec); 162 duration -= TimeDelta::FromSeconds(sleep_time.tv_sec);
170 sleep_time.tv_nsec = duration.InMicroseconds() * 1000; // nanoseconds 163 sleep_time.tv_nsec = duration.InMicroseconds() * 1000; // nanoseconds
171 164
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 #if !defined(OS_MACOSX) 243 #if !defined(OS_MACOSX)
251 // Mac OS X uses lower-level mach APIs. 244 // Mac OS X uses lower-level mach APIs.
252 245
253 // static 246 // static
254 void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) { 247 void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) {
255 // TODO(crogers): Implement, see http://crbug.com/116172 248 // TODO(crogers): Implement, see http://crbug.com/116172
256 } 249 }
257 #endif 250 #endif
258 251
259 } // namespace base 252 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698