diff options
| author | Michael Bebenita <[email protected]> | 2010-07-28 16:46:13 -0700 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2010-07-28 20:30:29 -0700 |
| commit | 4246d567b7a999155524669e3b0419e8f71080b1 (patch) | |
| tree | 38ab4d3aa04b25e37db9e663890235edf2f3a8a6 /src/rt/rust_comm.cpp | |
| parent | Move notification-messages out into their own file and unify into notify_mess... (diff) | |
| download | rust-4246d567b7a999155524669e3b0419e8f71080b1.tar.xz rust-4246d567b7a999155524669e3b0419e8f71080b1.zip | |
Move ports out into their own file, add data_message and make communication system use it (and proxies) instead of existing token scheme.
Diffstat (limited to 'src/rt/rust_comm.cpp')
| -rw-r--r-- | src/rt/rust_comm.cpp | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/src/rt/rust_comm.cpp b/src/rt/rust_comm.cpp index 37929b8b..3fbaaa04 100644 --- a/src/rt/rust_comm.cpp +++ b/src/rt/rust_comm.cpp @@ -1,87 +1,13 @@ #include "rust_internal.h" -template class ptr_vec<rust_token>; template class ptr_vec<rust_alarm>; -template class ptr_vec<rust_chan>; rust_alarm::rust_alarm(rust_task *receiver) : receiver(receiver) { } -// Ports. - -rust_port::rust_port(rust_task *task, size_t unit_sz) : - task(task), - unit_sz(unit_sz), - writers(task->dom), - chans(task->dom) -{ - task->log(rust_log::MEM|rust_log::COMM, - "new rust_port(task=0x%" PRIxPTR ", unit_sz=%d) -> port=0x%" - PRIxPTR, (uintptr_t)task, unit_sz, (uintptr_t)this); -} - -rust_port::~rust_port() -{ - task->log(rust_log::COMM|rust_log::MEM, - "~rust_port 0x%" PRIxPTR, - (uintptr_t)this); - while (chans.length() > 0) - chans.pop()->disassociate(); -} - - -// Tokens. - -rust_token::rust_token(rust_chan *chan) : - chan(chan), - idx(0), - submitted(false) -{ -} - -rust_token::~rust_token() -{ -} - -bool -rust_token::pending() const -{ - return submitted; -} - -void -rust_token::submit() -{ - rust_port *port = chan->port; - rust_dom *dom = chan->task->dom; - - I(dom, port); - I(dom, !submitted); - - port->writers.push(this); - submitted = true; -} - -void -rust_token::withdraw() -{ - rust_task *task = chan->task; - rust_port *port = chan->port; - rust_dom *dom = task->dom; - - I(dom, port); - I(dom, submitted); - - if (task->blocked()) - task->wakeup(this); // must be blocked on us (or dead) - port->writers.swap_delete(this); - submitted = false; -} - - // // Local Variables: // mode: C++ |