diff options
author | Alex Gorrod <alexg@wiredtiger.com> | 2015-09-28 04:21:23 +0000 |
---|---|---|
committer | Alex Gorrod <alexg@wiredtiger.com> | 2015-09-28 04:21:23 +0000 |
commit | 744696e318c0d8042f32f8ab5d858fa1a8365d69 (patch) | |
tree | 1fb0d0ca83c785b4e8d59de7756ece1909a51be6 /src/include/mutex.i | |
parent | b8d17a07e4e209756407a9ca30fe233d551aee84 (diff) | |
download | mongo-744696e318c0d8042f32f8ab5d858fa1a8365d69.tar.gz |
WT-2131 Switch all WT_PAGE_RECONCILIATION locks to fair locks.
The main purpose is to keep a single lock for all page operations.
Diffstat (limited to 'src/include/mutex.i')
-rw-r--r-- | src/include/mutex.i | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/include/mutex.i b/src/include/mutex.i index 47d2e24ee73..1f6445c5315 100644 --- a/src/include/mutex.i +++ b/src/include/mutex.i @@ -253,6 +253,26 @@ __wt_spin_unlock(WT_SESSION_IMPL *session, WT_SPINLOCK *t) #endif /* + * __wt_fair_trylock -- + * Try to get a lock - give up if it is not immediately available. + */ +static inline int +__wt_fair_trylock(WT_SESSION_IMPL *session, WT_FAIR_LOCK *lock) +{ + uint16_t ticket; + + WT_UNUSED(session); + + /* Do the cheap test first. */ + if (lock->waiter != lock->owner) + return (EBUSY); + + ticket = lock->owner; + return (__wt_atomic_cas16( + &lock->waiter, ticket, ticket + 1) ? 0 : EBUSY); +} + +/* * __wt_fair_lock -- * Get a lock. */ |