rt: Move some code from rust_port_detach into rust_port::detach

This commit is contained in:
Brian Anderson 2012-03-03 02:50:23 -08:00
parent 93fa933a19
commit 8e0efce0da
2 changed files with 6 additions and 6 deletions

View file

@ -486,12 +486,6 @@ rust_port_detach(rust_port *port) {
rust_task *task = rust_task_thread::get_task(); rust_task *task = rust_task_thread::get_task();
LOG(task, comm, "rust_port_detach(0x%" PRIxPTR ")", (uintptr_t) port); LOG(task, comm, "rust_port_detach(0x%" PRIxPTR ")", (uintptr_t) port);
port->detach(); port->detach();
// FIXME: Busy waiting until we're the only ref
bool done = false;
while (!done) {
scoped_lock with(task->port_lock);
done = port->ref_count == 1;
}
} }
extern "C" CDECL void extern "C" CDECL void

View file

@ -22,6 +22,12 @@ rust_port::~rust_port() {
void rust_port::detach() { void rust_port::detach() {
task->release_port(id); task->release_port(id);
// FIXME: Busy waiting until we're the only ref
bool done = false;
while (!done) {
scoped_lock with(task->port_lock);
done = ref_count == 1;
}
} }
void rust_port::send(void *sptr) { void rust_port::send(void *sptr) {