Skip to content

Commit

Permalink
NonSend documentation, minor error message fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ratysz committed Feb 6, 2021
1 parent 42118c9 commit b532235
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 2 additions & 1 deletion crates/bevy_ecs/src/resource/resource_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ impl<'a, T: Resource + FromResources> DerefMut for Local<'a, T> {
}
}

// TODO: audit, document.
/// `NonSend<T>` resources cannot leave the main thread, so any system that wants access to
/// a non-send resource will run on the main thread. See `Resources::insert_non_send()` and friends.
#[derive(Debug)]
pub struct NonSend<'a, T: Resource> {
value: *mut T,
Expand Down
5 changes: 2 additions & 3 deletions crates/bevy_ecs/src/resource/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl Resources {

fn check_if_main_thread(&self) {
if std::thread::current().id() != self.main_thread_id {
panic!("Attempted to access a thread local resource off of the main thread.")
panic!("Attempted to access a non-send resource off of the main thread.")
}
}

Expand Down Expand Up @@ -282,7 +282,6 @@ impl Resources {
.unwrap_or_else(|| panic!("Resource does not exist {}.", std::any::type_name::<T>()))
}

// TODO: audit.
#[inline]
#[allow(clippy::missing_safety_doc)]
pub unsafe fn get_unsafe_non_send_ref<T: 'static>(&self) -> NonNull<T> {
Expand All @@ -295,7 +294,7 @@ impl Resources {
})
.unwrap_or_else(|| {
panic!(
"Thread-local resource does not exist {}.",
"Non-send resource does not exist {}.",
std::any::type_name::<T>()
)
})
Expand Down

0 comments on commit b532235

Please sign in to comment.