From 4246d567b7a999155524669e3b0419e8f71080b1 Mon Sep 17 00:00:00 2001 From: Michael Bebenita Date: Wed, 28 Jul 2010 16:46:13 -0700 Subject: Move ports out into their own file, add data_message and make communication system use it (and proxies) instead of existing token scheme. --- src/rt/rust_port.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/rt/rust_port.cpp (limited to 'src/rt/rust_port.cpp') diff --git a/src/rt/rust_port.cpp b/src/rt/rust_port.cpp new file mode 100644 index 00000000..0a5b7ee7 --- /dev/null +++ b/src/rt/rust_port.cpp @@ -0,0 +1,39 @@ +#include "rust_internal.h" +#include "rust_port.h" + +rust_port::rust_port(rust_task *task, size_t unit_sz) : + maybe_proxy(this), 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); + + // Allocate a remote channel, for remote channel data. + remote_channel = new (task->dom) rust_chan(task, this); +} + +rust_port::~rust_port() { + task->log(rust_log::COMM | rust_log::MEM, + "~rust_port 0x%" PRIxPTR, (uintptr_t) this); + + // Disassociate channels from this port. + while (chans.is_empty() == false) { + chans.pop()->disassociate(); + } + + // We're the only ones holding a reference to the remote channel, so + // clean it up. + delete remote_channel; +} + +// +// Local Variables: +// mode: C++ +// fill-column: 78; +// indent-tabs-mode: nil +// c-basic-offset: 4 +// buffer-file-coding-system: utf-8-unix +// compile-command: "make -k -C .. 2>&1 | sed -e 's/\\/x\\//x:\\//g'"; +// End: +// -- cgit v1.2.3