Commit 4152918 1 parent c0974ba commit 4152918 Copy full SHA for 4152918
File tree 2 files changed +14
-2
lines changed
2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -369,10 +369,16 @@ impl<S: Schedule> UnownedTask<S> {
369
369
let raw = self . raw ;
370
370
mem:: forget ( self ) ;
371
371
372
- // Poll the task
372
+ // Transfer one ref-count to a Task object.
373
+ let task = Task :: < S > {
374
+ raw,
375
+ _p : PhantomData ,
376
+ } ;
377
+
378
+ // Use the other ref-count to poll the task.
373
379
raw. poll ( ) ;
374
380
// Decrement our extra ref-count
375
- raw . header ( ) . state . ref_dec ( ) ;
381
+ drop ( task ) ;
376
382
}
377
383
378
384
pub ( crate ) fn shutdown ( self ) {
Original file line number Diff line number Diff line change @@ -111,6 +111,12 @@ fn create_shutdown2() {
111
111
drop ( join) ;
112
112
}
113
113
114
+ #[ test]
115
+ fn unowned_poll ( ) {
116
+ let ( task, _) = unowned ( async { } , NoopSchedule ) ;
117
+ task. run ( ) ;
118
+ }
119
+
114
120
#[ test]
115
121
fn schedule ( ) {
116
122
with ( |rt| {
You can’t perform that action at this time.
0 commit comments