Skip to content

Commit

Permalink
Merge #820
Browse files Browse the repository at this point in the history
820: Change AioCb to primarily use Bytes instead of Rc<[u8]> r=asomers a=asomers

`Rc<[u8]>` isn't a very good buffer type to use for aio.  For one thing, it lacks interior mutability.  For another, a single `Rc<[u8]>` can't be carved up into smaller buffers of the same type.  `Bytes` and `BytesMut` fix both problems.  This PR removes the ability to construct an `AioCb` from `Rc<[u8]>` and adds the ability to construct one from `Bytes`, `BytesMut`, or raw pointers (for consumers who need even more flexibility).  At this stage, the PR has the following warts:

1. A hack is necessary to force small `Bytes` buffers to allocate on the heap.  I plan to fix this with an enhancement to the bytes crate.
2. The `AioCb::buffer` method is necessary due to a deficiency in the tokio-core crate.  Once I fix that, then only `AioCb::into_buffer`will need to be public.
  • Loading branch information
bors[bot] committed Jan 18, 2018
2 parents 5f321db + c3ff37b commit 1c3e520
Show file tree
Hide file tree
Showing 6 changed files with 915 additions and 113 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]

### Added
- Added `AioCb::from_ptr` and `AioCb::from_mut_ptr`
([#820](https://github.com/nix-rust/nix/pull/820))
- Added specialized wrappers: `sys::ptrace::{traceme, syscall, cont, attach}`. Using the matching routines
with `sys::ptrace::ptrace` is now deprecated.
- Added `nix::poll` module for all platforms
Expand Down Expand Up @@ -108,6 +110,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
([#648](https://github.com/nix-rust/nix/pull/648))

### Removed
- `AioCb::from_boxed_slice` has been removed. It was never actually safe. Use
`from_bytes` or `from_bytes_mut` instead.
([#820](https://github.com/nix-rust/nix/pull/820))
- The syscall module has been removed. This only exposed enough functionality for
`memfd_create()` and `pivot_root()`, which are still exposed as separate functions.
([#747](https://github.com/nix-rust/nix/pull/747))
Expand Down
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ bitflags = "1.0"
cfg-if = "0.1.0"
void = "1.0.2"

[dependencies.bytes]
version = "0.4.5"
# Don't include the optional serde feature
default-features = false

[target.'cfg(target_os = "dragonfly")'.build-dependencies]
gcc = "0.3"

Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#![cfg_attr(test, deny(warnings))]
#![recursion_limit = "500"]

extern crate bytes;
#[macro_use]
extern crate bitflags;

Expand Down
Loading

0 comments on commit 1c3e520

Please sign in to comment.