Skip to content

Commit b039ac5

Browse files
committed
fix: resolve conflict on unix
1 parent b140828 commit b039ac5

File tree

3 files changed

+31
-28
lines changed

3 files changed

+31
-28
lines changed

compio-driver/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,12 @@ impl Proactor {
272272
}
273273
}
274274

275+
impl AsRawFd for Proactor {
276+
fn as_raw_fd(&self) -> RawFd {
277+
self.driver.as_raw_fd()
278+
}
279+
}
280+
275281
/// An completed entry returned from kernel.
276282
#[derive(Debug)]
277283
pub(crate) struct Entry {

compio-fs/src/stdio/unix.rs

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
use std::{io, mem::ManuallyDrop};
22

33
use compio_buf::{BufResult, IoBuf, IoBufMut, IoVectoredBuf, IoVectoredBufMut};
4-
use compio_driver::{FromRawFd, RawFd};
4+
use compio_driver::{AsRawFd, FromRawFd, RawFd};
55
use compio_io::{AsyncRead, AsyncWrite};
6-
use compio_runtime::TryAsRawFd;
76

87
use crate::pipe::{Receiver, Sender};
98

@@ -31,13 +30,9 @@ impl AsyncRead for Stdin {
3130
}
3231
}
3332

34-
impl TryAsRawFd for Stdin {
35-
fn try_as_raw_fd(&self) -> io::Result<RawFd> {
36-
self.0.try_as_raw_fd()
37-
}
38-
39-
unsafe fn as_raw_fd_unchecked(&self) -> RawFd {
40-
self.0.as_raw_fd_unchecked()
33+
impl AsRawFd for Stdin {
34+
fn as_raw_fd(&self) -> RawFd {
35+
self.0.as_raw_fd()
4136
}
4237
}
4338

@@ -73,13 +68,9 @@ impl AsyncWrite for Stdout {
7368
}
7469
}
7570

76-
impl TryAsRawFd for Stdout {
77-
fn try_as_raw_fd(&self) -> io::Result<RawFd> {
78-
self.0.try_as_raw_fd()
79-
}
80-
81-
unsafe fn as_raw_fd_unchecked(&self) -> RawFd {
82-
self.0.as_raw_fd_unchecked()
71+
impl AsRawFd for Stdout {
72+
fn as_raw_fd(&self) -> RawFd {
73+
self.0.as_raw_fd()
8374
}
8475
}
8576

@@ -115,12 +106,8 @@ impl AsyncWrite for Stderr {
115106
}
116107
}
117108

118-
impl TryAsRawFd for Stderr {
119-
fn try_as_raw_fd(&self) -> io::Result<RawFd> {
120-
self.0.try_as_raw_fd()
121-
}
122-
123-
unsafe fn as_raw_fd_unchecked(&self) -> RawFd {
124-
self.0.as_raw_fd_unchecked()
109+
impl AsRawFd for Stderr {
110+
fn as_raw_fd(&self) -> RawFd {
111+
self.0.as_raw_fd()
125112
}
126113
}

compio-runtime/src/runtime/mod.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ use std::{
1010

1111
use async_task::{Runnable, Task};
1212
use compio_buf::IntoInner;
13-
use compio_driver::{op::Asyncify, Key, OpCode, Proactor, ProactorBuilder, PushEntry, RawFd};
13+
use compio_driver::{
14+
op::Asyncify, AsRawFd, Key, OpCode, Proactor, ProactorBuilder, PushEntry, RawFd,
15+
};
1416
use compio_log::{debug, instrument};
1517
use crossbeam_queue::SegQueue;
1618
use futures_util::{future::Either, FutureExt};
@@ -57,10 +59,6 @@ impl RuntimeInner {
5759
})
5860
}
5961

60-
pub fn id(&self) -> usize {
61-
self.id
62-
}
63-
6462
// Safety: be careful about the captured lifetime.
6563
pub unsafe fn spawn_unchecked<F: Future>(&self, future: F) -> Task<F::Output> {
6664
let runnables = self.runnables.clone();
@@ -229,6 +227,12 @@ impl RuntimeInner {
229227
}
230228
}
231229

230+
impl AsRawFd for RuntimeInner {
231+
fn as_raw_fd(&self) -> RawFd {
232+
self.driver.borrow().as_raw_fd()
233+
}
234+
}
235+
232236
struct RuntimeContext {
233237
depth: usize,
234238
ptr: Weak<RuntimeInner>,
@@ -408,6 +412,12 @@ impl Runtime {
408412
}
409413
}
410414

415+
impl AsRawFd for Runtime {
416+
fn as_raw_fd(&self) -> RawFd {
417+
self.inner.as_raw_fd()
418+
}
419+
}
420+
411421
#[cfg(feature = "criterion")]
412422
impl criterion::async_executor::AsyncExecutor for Runtime {
413423
fn block_on<T>(&self, future: impl Future<Output = T>) -> T {

0 commit comments

Comments
 (0)