1
Fork 0

Make Span and Symbol implement Send and Sync

This commit is contained in:
John Kåre Alsaker 2017-12-03 14:37:23 +01:00
parent f53d4af223
commit 3fa69c935d
2 changed files with 10 additions and 2 deletions

View file

@ -184,8 +184,12 @@ impl SpanData {
}
}
// The interner in thread-local, so `Span` shouldn't move between threads.
// The interner is pointed to by a thread local value which is only set on the main thread
// with parallelization is disabled. So we don't allow Span to transfer between threads
// to avoid panics and other errors, even though it would be memory safe to do so.
#[cfg(not(parallel_queries))]
impl !Send for Span {}
#[cfg(not(parallel_queries))]
impl !Sync for Span {}
impl PartialOrd for Span {

View file

@ -83,8 +83,12 @@ impl Decodable for Ident {
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Symbol(u32);
// The interner in thread-local, so `Symbol` shouldn't move between threads.
// The interner is pointed to by a thread local value which is only set on the main thread
// with parallelization is disabled. So we don't allow Symbol to transfer between threads
// to avoid panics and other errors, even though it would be memory safe to do so.
#[cfg(not(parallel_queries))]
impl !Send for Symbol { }
#[cfg(not(parallel_queries))]
impl !Sync for Symbol { }
impl Symbol {