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

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: Rebase onto master. Created 8 years, 6 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
« no previous file with comments | « base/threading/platform_thread.h ('k') | base/threading/platform_thread_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 return reinterpret_cast<int64>(pthread_self()); 169 return reinterpret_cast<int64>(pthread_self());
170 #endif 170 #endif
171 } 171 }
172 172
173 // static 173 // static
174 void PlatformThread::YieldCurrentThread() { 174 void PlatformThread::YieldCurrentThread() {
175 sched_yield(); 175 sched_yield();
176 } 176 }
177 177
178 // static 178 // static
179 void PlatformThread::Sleep(int duration_ms) {
180 // NOTE: This function will be supplanted by the other version of Sleep
181 // in the future. See issue 108171 for more information.
182 Sleep(TimeDelta::FromMilliseconds(duration_ms));
183 }
184
185 // static
186 void PlatformThread::Sleep(TimeDelta duration) { 179 void PlatformThread::Sleep(TimeDelta duration) {
187 struct timespec sleep_time, remaining; 180 struct timespec sleep_time, remaining;
188 181
189 // Break the duration into seconds and nanoseconds. 182 // Break the duration into seconds and nanoseconds.
190 // NOTE: TimeDelta's microseconds are int64s while timespec's 183 // NOTE: TimeDelta's microseconds are int64s while timespec's
191 // nanoseconds are longs, so this unpacking must prevent overflow. 184 // nanoseconds are longs, so this unpacking must prevent overflow.
192 sleep_time.tv_sec = duration.InSeconds(); 185 sleep_time.tv_sec = duration.InSeconds();
193 duration -= TimeDelta::FromSeconds(sleep_time.tv_sec); 186 duration -= TimeDelta::FromSeconds(sleep_time.tv_sec);
194 sleep_time.tv_nsec = duration.InMicroseconds() * 1000; // nanoseconds 187 sleep_time.tv_nsec = duration.InMicroseconds() * 1000; // nanoseconds
195 188
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 #if !defined(OS_MACOSX) 275 #if !defined(OS_MACOSX)
283 // Mac OS X uses lower-level mach APIs. 276 // Mac OS X uses lower-level mach APIs.
284 277
285 // static 278 // static
286 void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) { 279 void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) {
287 // TODO(crogers): Implement, see http://crbug.com/116172 280 // TODO(crogers): Implement, see http://crbug.com/116172
288 } 281 }
289 #endif 282 #endif
290 283
291 } // namespace base 284 } // namespace base
OLDNEW
« no previous file with comments | « base/threading/platform_thread.h ('k') | base/threading/platform_thread_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698