Browse Source

Provide a function to downgrade a cglock from a write lock to an intermediate variant.

nfactor-troky
Con Kolivas 11 years ago
parent
commit
5683a1144e
  1. 11
      miner.h

11
miner.h

@ -843,7 +843,7 @@ static inline void cglock_init(cglock_t *lock) @@ -843,7 +843,7 @@ static inline void cglock_init(cglock_t *lock)
rwlock_init(&lock->rwlock);
}
/* Read lock variant of cglock */
/* Read lock variant of cglock. Cannot be promoted. */
static inline void cg_rlock(cglock_t *lock)
{
mutex_lock(&lock->mutex);
@ -851,7 +851,8 @@ static inline void cg_rlock(cglock_t *lock) @@ -851,7 +851,8 @@ static inline void cg_rlock(cglock_t *lock)
mutex_unlock_noyield(&lock->mutex);
}
/* Intermediate variant of cglock */
/* Intermediate variant of cglock - behaves as a read lock but can be promoted
* to a write lock or demoted to read lock. */
static inline void cg_ilock(cglock_t *lock)
{
mutex_lock(&lock->mutex);
@ -878,6 +879,12 @@ static inline void cg_dwlock(cglock_t *lock) @@ -878,6 +879,12 @@ static inline void cg_dwlock(cglock_t *lock)
mutex_unlock_noyield(&lock->mutex);
}
/* Demote a write variant to an intermediate variant */
static inline void cg_dwilock(cglock_t *lock)
{
wr_unlock(&lock->rwlock);
}
/* Downgrade intermediate variant to a read lock */
static inline void cg_dlock(cglock_t *lock)
{

Loading…
Cancel
Save