forked from routerify/async-pipe-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change fixes panics (routerify#6) and unsafe code (routerify#5). This comes at the cost of an additional copy of the data send through the pipe and having a buffer in the state. All unsafe code is removed and the need for a custom `Drop` implementation which makes the code overall easier. We also provide an implementation for traits from `futures` which is behind a feature flag. We also add tests.
- Loading branch information
1 parent
859b420
commit 4a749ba
Showing
7 changed files
with
213 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,10 @@ | ||
use std::task::Waker; | ||
|
||
pub const BUFFER_SIZE: usize = 1024; | ||
|
||
pub(crate) struct State { | ||
pub(crate) reader_waker: Option<Waker>, | ||
pub(crate) writer_waker: Option<Waker>, | ||
pub(crate) data: Option<Data>, | ||
pub(crate) done_reading: bool, | ||
pub(crate) read: usize, | ||
pub(crate) done_cycle: bool, | ||
pub(crate) closed: bool, | ||
pub(crate) buffer: Vec<u8>, | ||
} | ||
|
||
pub(crate) struct Data { | ||
pub(crate) ptr: *const u8, | ||
pub(crate) len: usize, | ||
} | ||
|
||
unsafe impl Send for Data {} |
Oops, something went wrong.