diff options
| author | Michael Bebenita <mbebenita@mozilla.com> | 2010-07-19 14:05:18 -0700 |
|---|---|---|
| committer | Michael Bebenita <mbebenita@mozilla.com> | 2010-07-19 14:05:18 -0700 |
| commit | 00d1465d13980fc3acf650f182ee0723fbda0e06 (patch) | |
| tree | a73cf5f0f20c0bee6722b33d975eb930919fefdf /src/rt/rust_timer.cpp | |
| parent | 1f0656d9084970fcc02ba9c27277265b8b3b7217 (diff) | |
| download | rust-00d1465d13980fc3acf650f182ee0723fbda0e06.tar.gz rust-00d1465d13980fc3acf650f182ee0723fbda0e06.zip | |
Added a message passing system based on lock free queues for inter-thread communication. Channels now buffer on the sending side, and no longer require blocking when sending. Lots of other refactoring and bug fixes.
Diffstat (limited to 'src/rt/rust_timer.cpp')
| -rw-r--r-- | src/rt/rust_timer.cpp | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/src/rt/rust_timer.cpp b/src/rt/rust_timer.cpp index fdee30758fc..269942f5f80 100644 --- a/src/rt/rust_timer.cpp +++ b/src/rt/rust_timer.cpp @@ -1,4 +1,3 @@ - #include "rust_internal.h" #include "valgrind.h" @@ -27,12 +26,11 @@ static void * #else #error "Platform not supported" #endif -timer_loop(void *ptr) -{ +timer_loop(void *ptr) { // We were handed the rust_timer that owns us. rust_timer *timer = (rust_timer *)ptr; - rust_dom &dom = timer->dom; - dom.log(rust_log::TIMER, "in timer 0x%" PRIxPTR, (uintptr_t)timer); + rust_dom *dom = timer->dom; + dom->log(rust_log::TIMER, "in timer 0x%" PRIxPTR, (uintptr_t)timer); size_t ms = TIME_SLICE_IN_MS; if (!RUNNING_ON_VALGRIND) ms = 1; @@ -43,12 +41,10 @@ timer_loop(void *ptr) #else usleep(ms * 1000); #endif - dom.log(rust_log::TIMER, - "timer 0x%" PRIxPTR - " interrupting domain 0x%" PRIxPTR, - (uintptr_t)timer, - (uintptr_t)&dom); - dom.interrupt_flag = 1; + dom->log(rust_log::TIMER, "timer 0x%" PRIxPTR + " interrupting domain 0x%" PRIxPTR, (uintptr_t) timer, + (uintptr_t) dom); + dom->interrupt_flag = 1; } #if defined(__WIN32__) ExitThread(0); @@ -58,10 +54,9 @@ timer_loop(void *ptr) return 0; } - -rust_timer::rust_timer(rust_dom &dom) : dom(dom), exit_flag(0) -{ - dom.log(rust_log::TIMER, "creating timer for domain 0x%" PRIxPTR, &dom); +rust_timer::rust_timer(rust_dom *dom) : + dom(dom), exit_flag(0) { + dom->log(rust_log::TIMER, "creating timer for domain 0x%" PRIxPTR, dom); #if defined(__WIN32__) thread = CreateThread(NULL, 0, timer_loop, this, 0, NULL); dom.win32_require("CreateThread", thread != NULL); @@ -76,13 +71,11 @@ rust_timer::rust_timer(rust_dom &dom) : dom(dom), exit_flag(0) #endif } -rust_timer::~rust_timer() -{ +rust_timer::~rust_timer() { exit_flag = 1; #if defined(__WIN32__) - dom.win32_require("WaitForSingleObject", - WaitForSingleObject(thread, INFINITE) - == WAIT_OBJECT_0); + dom->win32_require("WaitForSingleObject", + WaitForSingleObject(thread, INFINITE) == WAIT_OBJECT_0); #else pthread_join(thread, NULL); #endif |
