Skip to content

Commit 32cb634

Browse files
committed
wip
1 parent fc94ec5 commit 32cb634

File tree

4 files changed

+38
-12
lines changed

4 files changed

+38
-12
lines changed

src/proactor.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
use std::task::{Context, Poll};
12
use std::time::Duration;
2-
use std::task::{Poll, Context};
3-
use std::{pin::Pin, future::Future, io};
3+
use std::{future::Future, io, pin::Pin};
44

55
use lever::prelude::*;
66
use once_cell::sync::Lazy;
@@ -9,6 +9,9 @@ use super::syscore::*;
99
use super::waker::*;
1010
use crate::spawn_blocking;
1111

12+
#[cfg(target_os = "windows")]
13+
use crate::syscore::iocp::SysProactor;
14+
1215
pub use super::handle::*;
1316

1417
///
@@ -18,9 +21,8 @@ pub struct Proactor(SysProactor);
1821
impl Proactor {
1922
/// Returns a reference to the proactor.
2023
pub fn get() -> &'static Proactor {
21-
static PROACTOR: Lazy<Proactor> = Lazy::new(|| Proactor(
22-
SysProactor::new().expect("cannot initialize poll backend")
23-
));
24+
static PROACTOR: Lazy<Proactor> =
25+
Lazy::new(|| Proactor(SysProactor::new().expect("cannot initialize poll backend")));
2426

2527
&PROACTOR
2628
}
@@ -52,10 +54,8 @@ pub fn drive<T>(future: impl Future<Output = T>) -> T {
5254
let cx = &mut Context::from_waker(&waker);
5355
futures_util::pin_mut!(future);
5456

55-
let driver = spawn_blocking(move || {
56-
loop {
57-
let _ = p.wait(1, None);
58-
}
57+
let driver = spawn_blocking(move || loop {
58+
let _ = p.wait(1, None);
5959
});
6060

6161
futures_util::pin_mut!(driver);
@@ -70,4 +70,4 @@ pub fn drive<T>(future: impl Future<Output = T>) -> T {
7070
let duration = Duration::from_millis(1);
7171
driver.as_mut().poll(cx);
7272
}
73-
}
73+
}

src/syscore/windows/iocp.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
pub struct SysProactor {}
2+
3+
impl SysProactor {
4+
/// Returns a reference to the proactor.
5+
pub fn new() -> Result<Self, ()> {
6+
Ok(Self {})
7+
}
8+
9+
/// Wakes the thread waiting on proactor.
10+
pub fn wake(&self) {
11+
todo!();
12+
}
13+
14+
/// Wait for completion of IO object
15+
pub fn wait(&self, max_event_size: usize, duration: Option<Duration>) -> io::Result<usize> {
16+
todo!();
17+
}
18+
19+
/// Get underlying proactor instance.
20+
pub(crate) fn inner(&self) -> &SysProactor {
21+
todo!();
22+
}
23+
}

src/syscore/windows/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
mod nethandle;
2-
mod iocp;
1+
pub mod iocp;
2+
pub mod nethandle;

src/syscore/windows/nethandle.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
struct SysProactor {}
2+
3+
impl SysProactor {}

0 commit comments

Comments
 (0)