diff options
| author | Graydon Hoare <graydon@mozilla.com> | 2010-06-23 21:03:09 -0700 |
|---|---|---|
| committer | Graydon Hoare <graydon@mozilla.com> | 2010-06-23 21:03:09 -0700 |
| commit | d6b7c96c3eb29b9244ece0c046d3f372ff432d04 (patch) | |
| tree | b425187e232966063ffc2f0d14c04a55d8f004ef /src/rt/rust_chan.cpp | |
| parent | c01efc669f09508b55eced32d3c88702578a7c3e (diff) | |
| download | rust-d6b7c96c3eb29b9244ece0c046d3f372ff432d04.tar.gz rust-d6b7c96c3eb29b9244ece0c046d3f372ff432d04.zip | |
Populate tree.
Diffstat (limited to 'src/rt/rust_chan.cpp')
| -rw-r--r-- | src/rt/rust_chan.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/rt/rust_chan.cpp b/src/rt/rust_chan.cpp new file mode 100644 index 00000000000..38f93a7da9f --- /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; +} |
