Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -262,16 +262,11 @@ The exact Tokio 1.42.0 revision is:

https://github.com/tokio-rs/tokio/tree/bb9d57017e100985f86d8ca41ac105ee9140423e/tokio/src/sync

Asyncband retains semaphore-based fair scheduling and substantially rewrote
RwLock's guard lifecycle. The private asyncband/src/rwlock/access.rs
implementation owns acquired permits in RAII tokens that release them through
Asyncband's usize-based semaphore on drop. Guards carry no destructor of their
own and project data by moving their token. Downgrading establishes a read
token before releasing the other permits. The public documentation and
examples were rewritten around access, projection, and owned lifetimes. The
standard ASF source headers cover these substantial modifications contributed
to Apache Asyncband; the incorporated Tokio-derived portions remain under the
MIT License below.
Asyncband substantially rewrote RwLock's guard lifecycle and documentation.
Private RAII access tokens release permits through Asyncband's semaphore.
The standard ASF source headers cover these substantial modifications
contributed to Apache Asyncband; the incorporated Tokio-derived portions
remain under the MIT License below.

Acquisition has no semaphore-close error, nonblocking methods return Option,
and max_readers is any NonZeroUsize instead of Tokio's restricted range. Mapped
Expand Down
8 changes: 4 additions & 4 deletions asyncband/src/rwlock/access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ impl<'a, T: ?Sized> ReadAccess<&'a RwLock<T>> {
/// Drops the value type so that mapped guards need not name it.
pub fn into_semaphore(self) -> ReadAccess<&'a Semaphore> {
let lock = self.owner;
// The token holds only a reference and no other resource, so
// skipping its drop leaks nothing.
// The new token takes over releasing the permit; forgetting this one avoids releasing it
// during the transfer. Its borrowed owner needs no cleanup.
std::mem::forget(self);
ReadAccess::new(&lock.s)
}
Expand Down Expand Up @@ -117,8 +117,8 @@ impl<'a, T: ?Sized> WriteAccess<&'a RwLock<T>> {
pub fn into_semaphore(self) -> WriteAccess<&'a Semaphore> {
let lock = self.owner;
let permits_acquired = self.permits_acquired;
// The token holds only a reference and no other resource, so
// skipping its drop leaks nothing.
// The new token takes over releasing the permits; forgetting this one avoids releasing them
// during the transfer. Its borrowed owner needs no cleanup.
std::mem::forget(self);
WriteAccess::new(&lock.s, permits_acquired)
}
Expand Down
3 changes: 0 additions & 3 deletions asyncband/src/rwlock/owned_write_guard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ pub struct OwnedRwLockWriteGuard<T: ?Sized> {
access: WriteAccess<Arc<RwLock<T>>>,
}

unsafe impl<T: ?Sized + Send + Sync> Send for OwnedRwLockWriteGuard<T> {}
unsafe impl<T: ?Sized + Send + Sync> Sync for OwnedRwLockWriteGuard<T> {}
Comment on lines -76 to -77

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have trait_tests.rs and compile_fail_tests to guard these traits.


impl<T: ?Sized + fmt::Debug> fmt::Debug for OwnedRwLockWriteGuard<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(&**self, f)
Expand Down
1 change: 0 additions & 1 deletion asyncband/src/rwlock/read_guard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ pub struct RwLockReadGuard<'a, T: ?Sized> {
}

unsafe impl<T: ?Sized + Sync> Send for RwLockReadGuard<'_, T> {}
unsafe impl<T: ?Sized + Send + Sync> Sync for RwLockReadGuard<'_, T> {}

impl<T: ?Sized + fmt::Debug> fmt::Debug for RwLockReadGuard<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down
3 changes: 0 additions & 3 deletions asyncband/src/rwlock/write_guard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ pub struct RwLockWriteGuard<'a, T: ?Sized> {
access: WriteAccess<&'a RwLock<T>>,
}

unsafe impl<T: ?Sized + Send + Sync> Send for RwLockWriteGuard<'_, T> {}
unsafe impl<T: ?Sized + Send + Sync> Sync for RwLockWriteGuard<'_, T> {}

impl<T: ?Sized + fmt::Debug> fmt::Debug for RwLockWriteGuard<'_, T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(&**self, f)
Expand Down
Loading