• Home
  • Raw
  • Download

Lines Matching full:mutex

9 use std::sync::Mutex as StdMutex;
12 /// A futures-aware mutex.
16 /// This mutex provides no fairness guarantees. Tasks may not acquire the mutex
20 pub struct Mutex<T: ?Sized> { struct
26 impl<T: ?Sized> fmt::Debug for Mutex<T> { implementation
29 f.debug_struct("Mutex") in fmt()
36 impl<T> From<T> for Mutex<T> { implementation
42 impl<T: Default> Default for Mutex<T> { implementation
73 impl<T> Mutex<T> { impl
74 /// Creates a new futures-aware mutex.
83 /// Consumes this mutex, returning the underlying data.
88 /// use futures::lock::Mutex;
90 /// let mutex = Mutex::new(0);
91 /// assert_eq!(mutex.into_inner(), 0);
98 impl<T: ?Sized> Mutex<T> { implementation
105 Some(MutexGuard { mutex: self }) in try_lock()
117 mutex: Some(self), in lock()
124 /// Since this call borrows the `Mutex` mutably, no actual locking needs to
131 /// use futures::lock::Mutex;
133 /// let mut mutex = Mutex::new(0);
134 /// *mutex.get_mut() = 10;
135 /// assert_eq!(*mutex.lock().await, 10);
140 // there's no need to lock the inner mutex. in get_mut()
161 self.state.fetch_and(!HAS_WAITERS, Ordering::Relaxed); // released by mutex unlock in remove_waker()
166 // Unlocks the mutex. Called by MutexGuard and MappedMutexGuard when they are
182 /// A future which resolves when the target mutex has been successfully acquired.
184 // `None` indicates that the mutex was successfully acquired.
185 mutex: Option<&'a Mutex<T>>, field
192 .field("was_acquired", &self.mutex.is_none()) in fmt()
193 .field("mutex", &self.mutex) in fmt()
207 self.mutex.is_none() in is_terminated()
215 let mutex = self.mutex.expect("polled MutexLockFuture after completion"); in poll() localVariable
217 if let Some(lock) = mutex.try_lock() { in poll()
218 mutex.remove_waker(self.wait_key, false); in poll()
219 self.mutex = None; in poll()
224 let mut waiters = mutex.waiters.lock().unwrap(); in poll()
228mutex.state.fetch_or(HAS_WAITERS, Ordering::Relaxed); // released by mutex unlock in poll()
237 if let Some(lock) = mutex.try_lock() { in poll()
238 mutex.remove_waker(self.wait_key, false); in poll()
239 self.mutex = None; in poll()
249 if let Some(mutex) = self.mutex { in drop()
250 // This future was dropped before it acquired the mutex. in drop()
254 mutex.remove_waker(self.wait_key, true); in drop()
263 mutex: &'a Mutex<T>, field
273 /// use futures::lock::{Mutex, MutexGuard};
275 /// let data = Mutex::new(Some("value".to_string()));
287 let mutex = this.mutex; in map() localVariable
288 let value = f(unsafe { &mut *this.mutex.value.get() }); in map()
292 MappedMutexGuard { mutex, value, _marker: PhantomData } in map()
300 .field("mutex", &self.mutex) in fmt()
307 self.mutex.unlock() in drop()
314 unsafe { &*self.mutex.value.get() } in deref()
320 unsafe { &mut *self.mutex.value.get() } in deref_mut()
327 mutex: &'a Mutex<T>, field
339 /// use futures::lock::{MappedMutexGuard, Mutex, MutexGuard};
341 /// let data = Mutex::new(Some("value".to_string()));
354 let mutex = this.mutex; in map() localVariable
359 MappedMutexGuard { mutex, value, _marker: PhantomData } in map()
367 .field("mutex", &self.mutex) in fmt()
374 self.mutex.unlock() in drop()
393 unsafe impl<T: ?Sized + Send> Send for Mutex<T> {} implementation
394 unsafe impl<T: ?Sized + Send> Sync for Mutex<T> {} implementation
411 let mutex = Mutex::new(42); in test_mutex_guard_debug_not_recurse() localVariable
412 let guard = mutex.try_lock().unwrap(); in test_mutex_guard_debug_not_recurse()