tools::runtime: pin_mut instead of unsafe block
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
1ecf4e6d20
commit
a86e703661
@ -7,6 +7,7 @@ use std::task::{Context, Poll, RawWaker, Waker};
|
|||||||
use std::thread::{self, Thread};
|
use std::thread::{self, Thread};
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
use pin_utils::pin_mut;
|
||||||
use tokio::runtime::{self, Runtime};
|
use tokio::runtime::{self, Runtime};
|
||||||
|
|
||||||
thread_local! {
|
thread_local! {
|
||||||
@ -154,9 +155,8 @@ pub fn main<F: Future>(fut: F) -> F::Output {
|
|||||||
block_on(fut)
|
block_on(fut)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn block_on_local_future<F: Future>(mut fut: F) -> F::Output {
|
fn block_on_local_future<F: Future>(fut: F) -> F::Output {
|
||||||
use std::pin::Pin;
|
pin_mut!(fut);
|
||||||
let mut fut = unsafe { Pin::new_unchecked(&mut fut) };
|
|
||||||
|
|
||||||
let waker = Arc::new(thread::current());
|
let waker = Arc::new(thread::current());
|
||||||
let waker = thread_waker_clone(Arc::into_raw(waker) as *const ());
|
let waker = thread_waker_clone(Arc::into_raw(waker) as *const ());
|
||||||
|
Loading…
Reference in New Issue
Block a user