diff --git a/LICENSE b/LICENSE index 22762c1e..643e18a4 100644 --- a/LICENSE +++ b/LICENSE @@ -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 diff --git a/asyncband/src/rwlock/access.rs b/asyncband/src/rwlock/access.rs index 6bd9e8c9..fd9637e4 100644 --- a/asyncband/src/rwlock/access.rs +++ b/asyncband/src/rwlock/access.rs @@ -70,8 +70,8 @@ impl<'a, T: ?Sized> ReadAccess<&'a RwLock> { /// 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) } @@ -117,8 +117,8 @@ impl<'a, T: ?Sized> WriteAccess<&'a RwLock> { 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) } diff --git a/asyncband/src/rwlock/owned_write_guard.rs b/asyncband/src/rwlock/owned_write_guard.rs index c9bd2aed..f97b2bca 100644 --- a/asyncband/src/rwlock/owned_write_guard.rs +++ b/asyncband/src/rwlock/owned_write_guard.rs @@ -73,9 +73,6 @@ pub struct OwnedRwLockWriteGuard { access: WriteAccess>>, } -unsafe impl Send for OwnedRwLockWriteGuard {} -unsafe impl Sync for OwnedRwLockWriteGuard {} - impl fmt::Debug for OwnedRwLockWriteGuard { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&**self, f) diff --git a/asyncband/src/rwlock/read_guard.rs b/asyncband/src/rwlock/read_guard.rs index e3f35d2c..0afd2b0c 100644 --- a/asyncband/src/rwlock/read_guard.rs +++ b/asyncband/src/rwlock/read_guard.rs @@ -70,7 +70,6 @@ pub struct RwLockReadGuard<'a, T: ?Sized> { } unsafe impl Send for RwLockReadGuard<'_, T> {} -unsafe impl Sync for RwLockReadGuard<'_, T> {} impl fmt::Debug for RwLockReadGuard<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/asyncband/src/rwlock/write_guard.rs b/asyncband/src/rwlock/write_guard.rs index 7cce4b94..965adfbd 100644 --- a/asyncband/src/rwlock/write_guard.rs +++ b/asyncband/src/rwlock/write_guard.rs @@ -66,9 +66,6 @@ pub struct RwLockWriteGuard<'a, T: ?Sized> { access: WriteAccess<&'a RwLock>, } -unsafe impl Send for RwLockWriteGuard<'_, T> {} -unsafe impl Sync for RwLockWriteGuard<'_, T> {} - impl fmt::Debug for RwLockWriteGuard<'_, T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&**self, f)