diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2014-11-26 10:10:52 -0500 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2014-12-14 04:21:56 -0500 |
| commit | d61338172fa110fcf9e5f2df0e1e83635d0fde3f (patch) | |
| tree | 5a022b681067ce30acf73e06aef9896f3cfd4be2 /src/libstd/rt | |
| parent | 10ac5b72f1974775bed499105c2a3cf18da98f32 (diff) | |
| download | rust-d61338172fa110fcf9e5f2df0e1e83635d0fde3f.tar.gz rust-d61338172fa110fcf9e5f2df0e1e83635d0fde3f.zip | |
Rewrite threading infrastructure, introducing `Thunk` to represent
boxed `FnOnce` closures.
Diffstat (limited to 'src/libstd/rt')
| -rw-r--r-- | src/libstd/rt/mod.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs index 5ecd3ff04f1..eb517047ddc 100644 --- a/src/libstd/rt/mod.rs +++ b/src/libstd/rt/mod.rs @@ -52,6 +52,7 @@ use borrow::IntoCow; use failure; use rustrt; use os; +use thunk::Thunk; // Reexport some of our utilities which are expected by other crates. pub use self::util::{default_sched_threads, min_stack, running_on_valgrind}; @@ -87,10 +88,10 @@ static OS_DEFAULT_STACK_ESTIMATE: uint = 2 * (1 << 20); #[lang = "start"] fn lang_start(main: *const u8, argc: int, argv: *const *const u8) -> int { use mem; - start(argc, argv, proc() { + start(argc, argv, Thunk::new(move|| { let main: extern "Rust" fn() = unsafe { mem::transmute(main) }; main(); - }) + })) } /// Executes the given procedure after initializing the runtime with the given @@ -102,7 +103,7 @@ fn lang_start(main: *const u8, argc: int, argv: *const *const u8) -> int { /// /// This function will only return once *all* native threads in the system have /// exited. -pub fn start(argc: int, argv: *const *const u8, main: proc()) -> int { +pub fn start(argc: int, argv: *const *const u8, main: Thunk) -> int { use prelude::*; use rt; use rustrt::task::Task; @@ -144,7 +145,7 @@ pub fn start(argc: int, argv: *const *const u8, main: proc()) -> int { unsafe { rustrt::stack::record_os_managed_stack_bounds(my_stack_bottom, my_stack_top); } - (main.take().unwrap())(); + (main.take().unwrap()).invoke(()); exit_code = Some(os::get_exit_status()); }).destroy()); unsafe { rt::cleanup(); } |
