From fa8e71a8257f4226ab532d4bf268d3ecbfa98eb4 Mon Sep 17 00:00:00 2001 From: Marvin Löbel Date: Fri, 11 Oct 2013 23:20:34 +0200 Subject: Allow fail messages to be caught, and introduce the Any trait Some code cleanup, sorting of import blocks Removed std::unstable::UnsafeArc's use of Either Added run-fail tests for the new FailWithCause impls Changed future_result and try to return Result<(), ~Any>. - Internally, there is an enum of possible fail messages passend around. - In case of linked failure or a string message, the ~Any gets lazyly allocated in future_results recv method. - For that, future result now returns a wrapper around a Port. - Moved and renamed task::TaskResult into rt::task::UnwindResult and made it an internal enum. - Introduced a replacement typedef `type TaskResult = Result<(), ~Any>`. --- src/libstd/rt/uv/uvio.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/libstd/rt/uv') diff --git a/src/libstd/rt/uv/uvio.rs b/src/libstd/rt/uv/uvio.rs index e0707a86f7b..5643f6445f1 100644 --- a/src/libstd/rt/uv/uvio.rs +++ b/src/libstd/rt/uv/uvio.rs @@ -1899,6 +1899,7 @@ fn test_simple_homed_udp_io_bind_then_move_task_then_home_and_close() { use rt::thread::Thread; use rt::task::Task; use rt::sched::{Shutdown, TaskFromFriend}; + use rt::task::UnwindResult; do run_in_bare_thread { let sleepers = SleeperList::new(); let work_queue1 = WorkQueue::new(); @@ -1916,10 +1917,10 @@ fn test_simple_homed_udp_io_bind_then_move_task_then_home_and_close() { let handle2 = Cell::new(sched2.make_handle()); let tasksFriendHandle = Cell::new(sched2.make_handle()); - let on_exit: ~fn(bool) = |exit_status| { + let on_exit: ~fn(UnwindResult) = |exit_status| { handle1.take().send(Shutdown); handle2.take().send(Shutdown); - rtassert!(exit_status); + rtassert!(exit_status.is_success()); }; let test_function: ~fn() = || { @@ -1978,6 +1979,7 @@ fn test_simple_homed_udp_io_bind_then_move_handle_then_home_and_close() { use rt::task::Task; use rt::comm::oneshot; use rt::sched::Shutdown; + use rt::task::UnwindResult; do run_in_bare_thread { let sleepers = SleeperList::new(); let work_queue1 = WorkQueue::new(); @@ -2017,10 +2019,10 @@ fn test_simple_homed_udp_io_bind_then_move_handle_then_home_and_close() { */ }; - let on_exit: ~fn(bool) = |exit| { + let on_exit: ~fn(UnwindResult) = |exit| { handle1.take().send(Shutdown); handle2.take().send(Shutdown); - rtassert!(exit); + rtassert!(exit.is_success()); }; let task1 = Cell::new(~Task::new_root(&mut sched1.stack_pool, None, body1)); @@ -2088,6 +2090,7 @@ fn test_simple_tcp_server_and_client_on_diff_threads() { use rt::thread::Thread; use rt::task::Task; use rt::sched::{Shutdown}; + use rt::task::UnwindResult; do run_in_bare_thread { let sleepers = SleeperList::new(); @@ -2108,14 +2111,14 @@ fn test_simple_tcp_server_and_client_on_diff_threads() { let server_handle = Cell::new(server_sched.make_handle()); let client_handle = Cell::new(client_sched.make_handle()); - let server_on_exit: ~fn(bool) = |exit_status| { + let server_on_exit: ~fn(UnwindResult) = |exit_status| { server_handle.take().send(Shutdown); - rtassert!(exit_status); + rtassert!(exit_status.is_success()); }; - let client_on_exit: ~fn(bool) = |exit_status| { + let client_on_exit: ~fn(UnwindResult) = |exit_status| { client_handle.take().send(Shutdown); - rtassert!(exit_status); + rtassert!(exit_status.is_success()); }; let server_fn: ~fn() = || { -- cgit 1.4.1-3-g733a5