Skip to content

Instantly share code, notes, and snippets.

#![feature(thread_spawn_unchecked)]
use std::any::Any;
use std::io;
use std::marker::PhantomData;
use std::ptr::NonNull;
use std::sync::Mutex;
use std::thread::Thread;
use std::thread::{self, JoinHandle};
@oliver-giersch
oliver-giersch / scoped.rs
Last active June 21, 2019 08:31
A minimal scoped thread implementation using the unstable "thread_spawn_unchecked" feature that allows join handles to safely leak from a scope
#![feature(thread_spawn_unchecked)]
use std::any::Any;
use std::cell::UnsafeCell;
use std::io;
use std::marker::PhantomData;
use std::mem;
use std::sync::Arc;
use std::sync::Mutex;
use std::thread::{self, JoinHandle};