Skip to content

Commit 595b97b

Browse files
committed
remove arc from executor
1 parent beb9632 commit 595b97b

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

crates/bevy_tasks/src/thread_executor.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use std::{
22
marker::PhantomData,
3-
sync::Arc,
43
thread::{self, ThreadId},
54
};
65

@@ -19,17 +18,16 @@ use futures_lite::Future;
1918
/// let count = Arc::new(AtomicI32::new(0));
2019
///
2120
/// // create some owned values that can be moved into another thread
22-
/// let thread_executor_clone = thread_executor.clone();
2321
/// let count_clone = count.clone();
2422
///
2523
/// std::thread::scope(|scope| {
2624
/// scope.spawn(|| {
2725
/// // we cannot get the ticker from another thread
28-
/// let not_thread_ticker = thread_executor_clone.ticker();
26+
/// let not_thread_ticker = thread_executor.ticker();
2927
/// assert!(not_thread_ticker.is_none());
3028
///
3129
/// // but we can spawn tasks from another thread
32-
/// thread_executor_clone.spawn(async move {
30+
/// thread_executor.spawn(async move {
3331
/// count_clone.fetch_add(1, Ordering::Relaxed);
3432
/// }).detach();
3533
/// });
@@ -43,16 +41,16 @@ use futures_lite::Future;
4341
/// thread_ticker.try_tick();
4442
/// assert_eq!(count.load(Ordering::Relaxed), 1);
4543
/// ```
46-
#[derive(Debug, Clone)]
44+
#[derive(Debug)]
4745
pub struct ThreadExecutor<'a> {
48-
executor: Arc<Executor<'a>>,
46+
executor: Executor<'a>,
4947
thread_id: ThreadId,
5048
}
5149

5250
impl<'a> Default for ThreadExecutor<'a> {
5351
fn default() -> Self {
5452
Self {
55-
executor: Arc::new(Executor::new()),
53+
executor: Executor::new(),
5654
thread_id: thread::current().id(),
5755
}
5856
}
@@ -76,7 +74,7 @@ impl<'a> ThreadExecutor<'a> {
7674
pub fn ticker<'b>(&'b self) -> Option<ThreadExecutorTicker<'a, 'b>> {
7775
if thread::current().id() == self.thread_id {
7876
return Some(ThreadExecutorTicker {
79-
executor: &*self.executor,
77+
executor: &self.executor,
8078
_marker: PhantomData::default(),
8179
});
8280
}

0 commit comments

Comments
 (0)