···4242 }
43434444 /// this function never blocks. (`fetch_update` loop doesn't count)
4545- #[inline]
4645 pub fn lock(&mut self) -> ReadGuard<'_, T> {
4746 let shared_ref = self.shared_ref();
4847···5857unsafe impl<T: Send> Send for Reader<T> {}
59586059impl<T> Drop for Reader<T> {
6161- #[inline]
6260 fn drop(&mut self) {
6361 // SAFETY: self.shared is valid and not used after this.
6462 unsafe { Shared::drop(self.shared) };
···8179impl<T> Deref for ReadGuard<'_, T> {
8280 type Target = T;
83818484- #[inline]
8582 fn deref(&self) -> &Self::Target {
8683 // SAFETY: ReadGuard was created, so the Writer knows not to write in this spot
8784 unsafe { self.shared.get_value_ref(self.value) }
···9390 E: ?Sized,
9491 T: AsRef<E>,
9592{
9696- #[inline]
9793 fn as_ref(&self) -> &E {
9894 self.deref().as_ref()
9995 }
···105101// unsafe impl<T: Sync> Sync for ReadGuard<'_, T> {}
106102107103impl<T> Drop for ReadGuard<'_, T> {
108108- #[inline]
109104 fn drop(&mut self) {
110105 // release the read lock
111106 self.shared.release_read_lock();
···152147 }
153148154149 /// get a Reader if none exists
155155- #[inline]
156150 pub fn build_reader(&mut self) -> Option<Reader<T>> {
157151 let shared_ref = self.shared_ref();
158152 // SAFETY: all is_unique_with_increase requirements are satisfied.
···190184impl<T: Clone, O> Writer<T, O> {
191185 /// Creates a new Writer by cloning the value once to get two values
192186 /// `T::clone()` shoulnd't give a different value, as that would make this library pretty useless
193193- #[inline]
194187 pub fn new(value: T) -> Self {
195188 let (shared, write_ptr) = Shared::new(value, |value_1| value_1.clone());
196189 Self {
···206199 /// Creates a new Writer by calling `T::default()` twice to create the two values
207200 ///
208201 /// Default impl of T needs to give the same result every time. Not upholding this doens't lead to UB, but turns the library basically useless
209209- #[inline]
210202 fn default() -> Self {
211203 let (shared, write_ptr) = Shared::new(T::default(), |_| T::default());
212204 Self {
···239231unsafe impl<T: Sync, O> Sync for Writer<T, O> {}
240232241233impl<T, O> Drop for Writer<T, O> {
242242- #[inline]
243234 fn drop(&mut self) {
244235 // SAFETY: self.shared is valid and not used after this.
245236 unsafe { Shared::drop(self.shared) };
···259250260251impl<T, O> WriteGuard<'_, T, O> {
261252 /// Makes the changes available to the reader. Equivalent to `std::mem::drop(self)`
262262- #[inline]
263253 pub fn swap(self) {}
264254265255 /// Gets the value currently being written to.
266266- #[inline]
267256 pub fn read(&self) -> &T {
268257 // SAFETY: Only the WriteGuard can write to the values / create mut refs to them.
269258 // The WriteGuard holds a mut ref to the writer so this function can't be called while a writeguard exists
···293282impl<T: Absorb<O>, O: Clone> WriteGuard<'_, T, O> {
294283 /// applies operation to the current write Value and stores it to apply to the other later.
295284 /// If there is no reader the operation is applied to both values immediately and not stored.
296296- #[inline]
297285 pub fn apply_op(&mut self, operation: O) {
298286 if let Some(shared) = self.writer.shared_mut() {
299287 shared.value_1.get_mut().absorb(operation.clone());
···312300// unsafe impl<T: Sync, O> Sync for WriteGuard<'_, T, O> {}
313301314302impl<T, O> Drop for WriteGuard<'_, T, O> {
315315- #[inline]
316303 fn drop(&mut self) {
317304 self.writer.swap();
318305 }