@@ -21,7 +21,6 @@ use futures_lite::Future;
21
21
/// // create some owned values that can be moved into another thread
22
22
/// let thread_executor_clone = thread_executor.clone();
23
23
/// let count_clone = count.clone();
24
- /// let thread_spawner = thread_executor.spawner();
25
24
///
26
25
/// std::thread::scope(|scope| {
27
26
/// scope.spawn(|| {
@@ -30,7 +29,7 @@ use futures_lite::Future;
30
29
/// assert!(not_thread_ticker.is_none());
31
30
///
32
31
/// // but we can spawn tasks from another thread
33
- /// thread_spawner .spawn(async move {
32
+ /// thread_executor_clone .spawn(async move {
34
33
/// count_clone.fetch_add(1, Ordering::Relaxed);
35
34
/// }).detach();
36
35
/// });
@@ -74,10 +73,10 @@ impl<'a> ThreadExecutor<'a> {
74
73
/// Use this to tick the executor.
75
74
/// It only returns the ticker if it's on the thread the executor was created on
76
75
/// and returns `None` otherwise.
77
- pub fn ticker ( & self ) -> Option < ThreadExecutorTicker < ' a > > {
76
+ pub fn ticker < ' b > ( & ' b self ) -> Option < ThreadExecutorTicker < ' a , ' b > > {
78
77
if thread:: current ( ) . id ( ) == self . thread_id {
79
78
return Some ( ThreadExecutorTicker {
80
- executor : self . executor . clone ( ) ,
79
+ executor : & * self . executor ,
81
80
_marker : PhantomData :: default ( ) ,
82
81
} ) ;
83
82
}
@@ -89,12 +88,12 @@ impl<'a> ThreadExecutor<'a> {
89
88
/// make progress unless it is manually ticked on the thread it was
90
89
/// created on.
91
90
#[ derive( Debug ) ]
92
- pub struct ThreadExecutorTicker < ' a > {
93
- executor : Arc < Executor < ' a > > ,
91
+ pub struct ThreadExecutorTicker < ' a , ' b > {
92
+ executor : & ' b Executor < ' a > ,
94
93
// make type not send or sync
95
94
_marker : PhantomData < * const ( ) > ,
96
95
}
97
- impl < ' a > ThreadExecutorTicker < ' a > {
96
+ impl < ' a , ' b > ThreadExecutorTicker < ' a , ' b > {
98
97
/// Tick the thread executor.
99
98
pub async fn tick ( & self ) {
100
99
self . executor . tick ( ) . await ;
0 commit comments