From 1b487a890695e7d6dfbfe5dcd7d4fa0e8ca8003f Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 27 Aug 2014 21:46:52 -0400 Subject: Implement generalized object and type parameter bounds (Fixes #16462) --- src/libsync/lock.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/libsync/lock.rs') diff --git a/src/libsync/lock.rs b/src/libsync/lock.rs index b07d06ca18e..e1cae6c62d5 100644 --- a/src/libsync/lock.rs +++ b/src/libsync/lock.rs @@ -180,6 +180,18 @@ pub struct Mutex { /// An guard which is created by locking a mutex. Through this guard the /// underlying data can be accessed. +#[cfg(not(stage0))] +pub struct MutexGuard<'a, T:'a> { + // FIXME #12808: strange name to try to avoid interfering with + // field accesses of the contained type via Deref + _data: &'a mut T, + /// Inner condition variable connected to the locked mutex that this guard + /// was created from. This can be used for atomic-unlock-and-deschedule. + pub cond: Condvar<'a>, +} + +/// stage0 only +#[cfg(stage0)] pub struct MutexGuard<'a, T> { // FIXME #12808: strange name to try to avoid interfering with // field accesses of the contained type via Deref @@ -280,6 +292,18 @@ pub struct RWLock { /// A guard which is created by locking an rwlock in write mode. Through this /// guard the underlying data can be accessed. +#[cfg(not(stage0))] +pub struct RWLockWriteGuard<'a, T:'a> { + // FIXME #12808: strange name to try to avoid interfering with + // field accesses of the contained type via Deref + _data: &'a mut T, + /// Inner condition variable that can be used to sleep on the write mode of + /// this rwlock. + pub cond: Condvar<'a>, +} + +/// stage0 only +#[cfg(stage0)] pub struct RWLockWriteGuard<'a, T> { // FIXME #12808: strange name to try to avoid interfering with // field accesses of the contained type via Deref @@ -291,6 +315,16 @@ pub struct RWLockWriteGuard<'a, T> { /// A guard which is created by locking an rwlock in read mode. Through this /// guard the underlying data can be accessed. +#[cfg(not(stage0))] +pub struct RWLockReadGuard<'a, T:'a> { + // FIXME #12808: strange names to try to avoid interfering with + // field accesses of the contained type via Deref + _data: &'a T, + _guard: raw::RWLockReadGuard<'a>, +} + +/// Stage0 only +#[cfg(stage0)] pub struct RWLockReadGuard<'a, T> { // FIXME #12808: strange names to try to avoid interfering with // field accesses of the contained type via Deref -- cgit 1.4.1-3-g733a5