From 04af99ecb0dee1cb3df0032f7e7ba08ffc6c5bd4 Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Mon, 8 Aug 2011 18:09:42 -0700 Subject: First step towards port handles. --- src/rt/rust_task.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/rt/rust_task.cpp') diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index fbee8896590..26ffcb307a5 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -75,6 +75,7 @@ rust_task::rust_task(rust_scheduler *sched, rust_task_list *state, cond_name("none"), supervisor(spawner), list_index(-1), + next_port_id(0), rendezvous_ptr(0), running_on(-1), pinned_on(-1), @@ -105,8 +106,6 @@ rust_task::~rust_task() del_stk(this, stk); } -extern "C" void rust_new_exit_task_glue(); - struct spawn_args { rust_task *task; uintptr_t a3; @@ -495,6 +494,26 @@ void rust_task::on_wakeup(rust_task::wakeup_callback *callback) { _on_wakeup = callback; } +rust_port_id rust_task::register_port(rust_port *port) { + scoped_lock with(lock); + + rust_port_id id = next_port_id++; + port_table.put(id, port); + return id; +} + +void rust_task::release_port(rust_port_id id) { + scoped_lock with(lock); + port_table.remove(id); +} + +rust_port *rust_task::get_port_by_id(rust_port_id id) { + scoped_lock with(lock); + rust_port *port = NULL; + port_table.get(id, &port); + return port; +} + // // Local Variables: // mode: C++ -- cgit 1.4.1-3-g733a5