diff options
| author | Michael Bebenita <mbebenita@mozilla.com> | 2010-09-10 01:21:29 -0700 |
|---|---|---|
| committer | Michael Bebenita <mbebenita@mozilla.com> | 2010-09-10 14:38:31 -0700 |
| commit | a493350eb5ab38ba8a6563f3eb4a090d257b0d3a (patch) | |
| tree | dc984eaa28a55de9f05db0b961a0e67f80ca35ef /src/rt/sync/sync.cpp | |
| parent | f985fded3ede8a7677ca6c9c77817d27bc9ae492 (diff) | |
| download | rust-a493350eb5ab38ba8a6563f3eb4a090d257b0d3a.tar.gz rust-a493350eb5ab38ba8a6563f3eb4a090d257b0d3a.zip | |
Cleanup, refactoring, and some runtime tests.
Diffstat (limited to 'src/rt/sync/sync.cpp')
| -rw-r--r-- | src/rt/sync/sync.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/rt/sync/sync.cpp b/src/rt/sync/sync.cpp index c754392aece..be874a115f0 100644 --- a/src/rt/sync/sync.cpp +++ b/src/rt/sync/sync.cpp @@ -11,6 +11,18 @@ void sync::yield() { #endif } +void sync::sleep(size_t timeout_in_ms) { +#ifdef __WIN32__ + Sleep(timeout_in_ms); +#else + usleep(timeout_in_ms * 1000); +#endif +} + +void sync::random_sleep(size_t max_timeout_in_ms) { + sleep(rand() % max_timeout_in_ms); +} + rust_thread::rust_thread() : _is_running(false), thread(0) { // Nop. } |
