Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions src/libstd/thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,14 @@ impl Builder {
#[stable(feature = "rust1", since = "1.0.0")]
pub fn spawn<F, T>(self, f: F) -> io::Result<JoinHandle<T>> where
F: FnOnce() -> T, F: Send + 'static, T: Send + 'static
{
unsafe { self.spawn_unchecked(f) }
}

/// FIXME: Doc
#[unstable(feature = "thread_spawn_unchecked", issue = "0")]
pub unsafe fn spawn_unchecked<'a, F, T>(self, f: F) -> io::Result<JoinHandle<T>> where
F: FnOnce() -> T, F: Send + 'a, T: Send + 'a
Comment thread
oliver-giersch marked this conversation as resolved.
Outdated
{
let Builder { name, stack_size } = self;

Expand All @@ -402,22 +410,19 @@ impl Builder {
if let Some(name) = their_thread.cname() {
imp::Thread::set_name(name);
}
unsafe {
thread_info::set(imp::guard::current(), their_thread);
#[cfg(feature = "backtrace")]
let try_result = panic::catch_unwind(panic::AssertUnwindSafe(|| {
::sys_common::backtrace::__rust_begin_short_backtrace(f)
}));
#[cfg(not(feature = "backtrace"))]
let try_result = panic::catch_unwind(panic::AssertUnwindSafe(f));
*their_packet.get() = Some(try_result);
}

thread_info::set(imp::guard::current(), their_thread);
Comment thread
RalfJung marked this conversation as resolved.
#[cfg(feature = "backtrace")]
let try_result = panic::catch_unwind(panic::AssertUnwindSafe(|| {
::sys_common::backtrace::__rust_begin_short_backtrace(f)
}));
#[cfg(not(feature = "backtrace"))]
let try_result = panic::catch_unwind(panic::AssertUnwindSafe(f));
*their_packet.get() = Some(try_result);
};

Ok(JoinHandle(JoinInner {
native: unsafe {
Some(imp::Thread::new(stack_size, Box::new(main))?)
},
native: Some(imp::Thread::new(stack_size, Box::new(main))?),
thread: my_thread,
packet: Packet(my_packet),
}))
Expand Down