• Home
  • Raw
  • Download

Lines Matching full:rwlock

39 /// become available to yield. An `RwLock` will allow any number of readers to
48 /// `std::sync::RwLock`, where the priority policy is dependent on the
60 /// use tokio::sync::RwLock;
64 /// let lock = RwLock::new(5);
84 /// [`RwLock`]: struct@RwLock
90 pub struct RwLock<T: ?Sized> { struct
113 check_send::<RwLock<u32>>(); in bounds() argument
114 check_sync::<RwLock<u32>>(); in bounds()
115 check_unpin::<RwLock<u32>>(); in bounds()
141 let rwlock = Arc::new(RwLock::new(0)); in bounds() localVariable
142 check_send_sync_val(rwlock.read()); in bounds()
143 check_send_sync_val(Arc::clone(&rwlock).read_owned()); in bounds()
144 check_send_sync_val(rwlock.write()); in bounds()
145 check_send_sync_val(Arc::clone(&rwlock).write_owned()); in bounds()
148 // As long as T: Send + Sync, it's fine to send and share RwLock<T> between threads.
149 // If T were not Send, sending and sharing a RwLock<T> would be bad, since you can access T through
150 // RwLock<T>.
151 unsafe impl<T> Send for RwLock<T> where T: ?Sized + Send {} implementation
152 unsafe impl<T> Sync for RwLock<T> where T: ?Sized + Send + Sync {} implementation
159 // the RwLock, unlike RwLockReadGuard.
195 impl<T: ?Sized> RwLock<T> { impl
196 /// Creates a new instance of an `RwLock<T>` which is unlocked.
201 /// use tokio::sync::RwLock;
203 /// let lock = RwLock::new(5);
206 pub fn new(value: T) -> RwLock<T> in new()
215 concrete_type = "RwLock", in new()
248 RwLock { in new()
257 /// Creates a new instance of an `RwLock<T>` which is unlocked
263 /// use tokio::sync::RwLock;
265 /// let lock = RwLock::with_max_readers(5, 1024);
272 pub fn with_max_readers(value: T, max_reads: u32) -> RwLock<T> in with_max_readers()
278 "a RwLock may not be created with more than {} readers", in with_max_readers()
288 concrete_type = "RwLock", in with_max_readers()
321 RwLock { in with_max_readers()
330 /// Creates a new instance of an `RwLock<T>` which is unlocked.
335 /// use tokio::sync::RwLock;
337 /// static LOCK: RwLock<i32> = RwLock::const_new(5);
341 pub const fn const_new(value: T) -> RwLock<T> in const_new()
345 RwLock { in const_new()
354 /// Creates a new instance of an `RwLock<T>` which is unlocked
360 /// use tokio::sync::RwLock;
362 /// static LOCK: RwLock<i32> = RwLock::const_with_max_readers(5, 1024);
366 pub const fn const_with_max_readers(value: T, mut max_reads: u32) -> RwLock<T> in const_with_max_readers()
371 RwLock { in const_with_max_readers()
380 /// Locks this `RwLock` with shared read access, causing the current task
386 /// Note that under the priority policy of [`RwLock`], read locks are not
392 /// Returns an RAII guard which will drop this read access of the `RwLock`
405 /// use tokio::sync::RwLock;
409 /// let lock = Arc::new(RwLock::new(1));
430 "RwLock::read", in read()
462 /// Blockingly locks this `RwLock` with shared read access.
465 /// need to use this rwlock in asynchronous code as well as in synchronous code.
467 /// Returns an RAII guard which will drop the read access of this `RwLock` when dropped.
483 /// use tokio::sync::RwLock;
487 /// let rwlock = Arc::new(RwLock::new(1));
488 /// let mut write_lock = rwlock.write().await;
491 /// let rwlock = Arc::clone(&rwlock);
494 /// let read_lock = rwlock.blocking_read();
506 /// assert!(rwlock.try_write().is_ok());
515 /// Locks this `RwLock` with shared read access, causing the current task
521 /// This method is identical to [`RwLock::read`], except that the returned
522 /// guard references the `RwLock` with an [`Arc`] rather than by borrowing
523 /// it. Therefore, the `RwLock` must be wrapped in an `Arc` to call this
525 /// the `RwLock` alive by holding an `Arc`.
527 /// Note that under the priority policy of [`RwLock`], read locks are not
533 /// Returns an RAII guard which will drop this read access of the `RwLock`
546 /// use tokio::sync::RwLock;
550 /// let lock = Arc::new(RwLock::new(1));
571 "RwLock::read_owned", in read_owned()
606 /// Attempts to acquire this `RwLock` with shared read access.
618 /// use tokio::sync::RwLock;
622 /// let lock = Arc::new(RwLock::new(1));
663 /// Attempts to acquire this `RwLock` with shared read access.
669 /// This method is identical to [`RwLock::try_read`], except that the
670 /// returned guard references the `RwLock` with an [`Arc`] rather than by
671 /// borrowing it. Therefore, the `RwLock` must be wrapped in an `Arc` to
673 /// as it keeps the `RwLock` alive by holding an `Arc`.
681 /// use tokio::sync::RwLock;
685 /// let lock = Arc::new(RwLock::new(1));
729 /// Locks this `RwLock` with exclusive write access, causing the current
735 /// Returns an RAII guard which will drop the write access of this `RwLock`
747 /// use tokio::sync::RwLock;
751 /// let lock = RwLock::new(1);
762 "RwLock::write", in write()
795 /// Blockingly locks this `RwLock` with exclusive write access.
798 /// need to use this rwlock in asynchronous code as well as in synchronous code.
800 /// Returns an RAII guard which will drop the write access of this `RwLock` when dropped.
816 /// use tokio::{sync::RwLock};
820 /// let rwlock = Arc::new(RwLock::new(1));
821 /// let read_lock = rwlock.read().await;
824 /// let rwlock = Arc::clone(&rwlock);
827 /// let mut write_lock = rwlock.blocking_write();
840 /// let read_lock = rwlock.try_read().unwrap();
850 /// Locks this `RwLock` with exclusive write access, causing the current
856 /// This method is identical to [`RwLock::write`], except that the returned
857 /// guard references the `RwLock` with an [`Arc`] rather than by borrowing
858 /// it. Therefore, the `RwLock` must be wrapped in an `Arc` to call this
860 /// the `RwLock` alive by holding an `Arc`.
862 /// Returns an RAII guard which will drop the write access of this `RwLock`
875 /// use tokio::sync::RwLock;
879 /// let lock = Arc::new(RwLock::new(1));
890 "RwLock::write_owned", in write_owned()
926 /// Attempts to acquire this `RwLock` with exclusive write access.
937 /// use tokio::sync::RwLock;
941 /// let rw = RwLock::new(1);
975 /// Attempts to acquire this `RwLock` with exclusive write access.
981 /// This method is identical to [`RwLock::try_write`], except that the
982 /// returned guard references the `RwLock` with an [`Arc`] rather than by
983 /// borrowing it. Therefore, the `RwLock` must be wrapped in an `Arc` to
985 /// as it keeps the `RwLock` alive by holding an `Arc`.
993 /// use tokio::sync::RwLock;
997 /// let rw = Arc::new(RwLock::new(1));
1036 /// Since this call borrows the `RwLock` mutably, no actual locking needs to
1042 /// use tokio::sync::RwLock;
1045 /// let mut lock = RwLock::new(1);
1067 impl<T> From<T> for RwLock<T> { implementation
1073 impl<T: ?Sized> Default for RwLock<T> implementation