Skip to content

Commit 5d228cd

Browse files
committed
rename related structs to be more clear
1 parent aa678b3 commit 5d228cd

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

crates/bevy_tasks/src/task_pool.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use concurrent_queue::ConcurrentQueue;
1111
use futures_lite::{future, pin, FutureExt};
1212

1313
use crate::{
14-
thread_executor::{ThreadExecutor, ThreadSpawner},
14+
thread_executor::{ThreadExecutor, ThreadExecutorSpawner},
1515
Task,
1616
};
1717

@@ -284,7 +284,8 @@ impl TaskPool {
284284
let executor: &async_executor::Executor = &self.executor;
285285
let executor: &'env async_executor::Executor = unsafe { mem::transmute(executor) };
286286
let thread_spawner = thread_executor.spawner();
287-
let thread_spawner: ThreadSpawner<'env> = unsafe { mem::transmute(thread_spawner) };
287+
let thread_spawner: ThreadExecutorSpawner<'env> =
288+
unsafe { mem::transmute(thread_spawner) };
288289
let spawned: ConcurrentQueue<FallibleTask<T>> = ConcurrentQueue::unbounded();
289290
let spawned_ref: &'env ConcurrentQueue<FallibleTask<T>> =
290291
unsafe { mem::transmute(&spawned) };
@@ -401,7 +402,7 @@ impl Drop for TaskPool {
401402
#[derive(Debug)]
402403
pub struct Scope<'scope, 'env: 'scope, T> {
403404
executor: &'scope async_executor::Executor<'scope>,
404-
thread_spawner: ThreadSpawner<'scope>,
405+
thread_spawner: ThreadExecutorSpawner<'scope>,
405406
spawned: &'scope ConcurrentQueue<FallibleTask<T>>,
406407
// make `Scope` invariant over 'scope and 'env
407408
scope: PhantomData<&'scope mut &'scope ()>,

crates/bevy_tasks/src/thread_executor.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,17 @@ impl ThreadExecutor {
6767

6868
/// Gets the `[ThreadSpawner]` for the thread executor.
6969
/// Use this to spawn tasks that run on the thread this was instantiated on.
70-
pub fn spawner(&self) -> ThreadSpawner<'static> {
71-
ThreadSpawner(self.executor.clone())
70+
pub fn spawner(&self) -> ThreadExecutorSpawner<'static> {
71+
ThreadExecutorSpawner(self.executor.clone())
7272
}
7373

7474
/// Gets the `[ThreadTicker]` for this executor.
7575
/// Use this to tick the executor.
7676
/// It only returns the ticker if it's on the thread the executor was created on
7777
/// and returns `None` otherwise.
78-
pub fn ticker(&self) -> Option<ThreadTicker> {
78+
pub fn ticker(&self) -> Option<ThreadExecutorTicker> {
7979
if thread::current().id() == self.thread_id {
80-
return Some(ThreadTicker {
80+
return Some(ThreadExecutorTicker {
8181
executor: self.executor.clone(),
8282
_marker: PhantomData::default(),
8383
});
@@ -88,8 +88,8 @@ impl ThreadExecutor {
8888

8989
/// Used to spawn on the [`ThreadExecutor`]
9090
#[derive(Debug, Clone)]
91-
pub struct ThreadSpawner<'a>(Arc<Executor<'a>>);
92-
impl<'a> ThreadSpawner<'a> {
91+
pub struct ThreadExecutorSpawner<'a>(Arc<Executor<'a>>);
92+
impl<'a> ThreadExecutorSpawner<'a> {
9393
/// Spawn a task on the thread executor
9494
pub fn spawn<T: Send + 'a>(&self, future: impl Future<Output = T> + Send + 'a) -> Task<T> {
9595
self.0.spawn(future)
@@ -100,12 +100,12 @@ impl<'a> ThreadSpawner<'a> {
100100
/// make progress unless it is manually ticked on the thread it was
101101
/// created on.
102102
#[derive(Debug)]
103-
pub struct ThreadTicker {
103+
pub struct ThreadExecutorTicker {
104104
executor: Arc<Executor<'static>>,
105105
// make type not send or sync
106106
_marker: PhantomData<*const ()>,
107107
}
108-
impl ThreadTicker {
108+
impl ThreadExecutorTicker {
109109
/// Tick the thread executor.
110110
pub fn tick(&self) -> impl Future<Output = ()> + '_ {
111111
self.executor.tick()

0 commit comments

Comments
 (0)