From 1347d04bb086f6d76dd7287762d34ef4c57dbc00 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 4 Mar 2012 16:52:19 -0800 Subject: rt: Properly block tasks while waiting for port detach --- src/rt/rust_builtin.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/rt/rust_builtin.cpp') diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index c37944c3760..14b18a99252 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -482,18 +482,23 @@ new_port(size_t unit_sz) { } extern "C" CDECL void -rust_port_detach(rust_port *port) { +rust_port_begin_detach(rust_port *port, uintptr_t *yield) { rust_task *task = rust_task_thread::get_task(); LOG(task, comm, "rust_port_detach(0x%" PRIxPTR ")", (uintptr_t) port); - port->detach(); + port->begin_detach(yield); +} + +extern "C" CDECL void +rust_port_end_detach(rust_port *port) { + port->end_detach(); } extern "C" CDECL void del_port(rust_port *port) { rust_task *task = rust_task_thread::get_task(); LOG(task, comm, "del_port(0x%" PRIxPTR ")", (uintptr_t) port); - A(task->thread, port->get_ref_count() == 1, "Expected port ref_count == 1"); - port->deref(); + A(task->thread, port->get_ref_count() == 0, "Expected port ref_count == 0"); + delete port; } extern "C" CDECL size_t -- cgit 1.4.1-3-g733a5