From d6b7c96c3eb29b9244ece0c046d3f372ff432d04 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Wed, 23 Jun 2010 21:03:09 -0700 Subject: Populate tree. --- src/rt/rust_chan.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/rt/rust_chan.cpp (limited to 'src/rt/rust_chan.cpp') diff --git a/src/rt/rust_chan.cpp b/src/rt/rust_chan.cpp new file mode 100644 index 00000000..38f93a7d --- /dev/null +++ b/src/rt/rust_chan.cpp @@ -0,0 +1,34 @@ + +#include "rust_internal.h" +#include "rust_chan.h" + +rust_chan::rust_chan(rust_task *task, rust_port *port) : + task(task), + port(port), + buffer(task->dom, port->unit_sz), + token(this) +{ + if (port) + port->chans.push(this); +} + +rust_chan::~rust_chan() +{ + if (port) { + if (token.pending()) + token.withdraw(); + port->chans.swapdel(this); + } +} + +void +rust_chan::disassociate() +{ + I(task->dom, port); + + if (token.pending()) + token.withdraw(); + + // Delete reference to the port/ + port = NULL; +} -- cgit v1.2.3