InnoDB Plugin  1.0
Functions | Variables
sync0rw.ic File Reference
This graph shows which files directly or indirectly include this file:

Functions

UNIV_INTERN void rw_lock_s_lock_spin (rw_lock_t *lock, ulint pass, const char *file_name, ulint line)
UNIV_INTERN void rw_lock_add_debug_info (rw_lock_t *lock, ulint pass, ulint lock_type, const char *file_name, ulint line)
UNIV_INTERN void rw_lock_remove_debug_info (rw_lock_t *lock, ulint pass, ulint lock_type)
UNIV_INLINE ulint rw_lock_get_waiters (const rw_lock_t *lock)
UNIV_INLINE void rw_lock_set_waiter_flag (rw_lock_t *lock)
UNIV_INLINE void rw_lock_reset_waiter_flag (rw_lock_t *lock)
UNIV_INLINE ulint rw_lock_get_writer (const rw_lock_t *lock)
UNIV_INLINE ulint rw_lock_get_reader_count (const rw_lock_t *lock)
UNIV_INLINE ib_mutex_trw_lock_get_mutex (rw_lock_t *lock)
UNIV_INLINE ulint rw_lock_get_x_lock_count (const rw_lock_t *lock)
UNIV_INLINE ibool rw_lock_lock_word_decr (rw_lock_t *lock, ulint amount)
UNIV_INLINE lint rw_lock_lock_word_incr (rw_lock_t *lock, ulint amount)
UNIV_INLINE void rw_lock_set_writer_id_and_recursion_flag (rw_lock_t *lock, ibool recursive)
UNIV_INLINE ibool rw_lock_s_lock_low (rw_lock_t *lock, ulint pass)
UNIV_INLINE ibool const char
ulint line 
if (!rw_lock_lock_word_decr(lock, 1))
 rw_lock_add_debug_info (lock, pass, RW_LOCK_SHARED, file_name, line)
 return (TRUE)
UNIV_INLINE void rw_lock_s_lock_func (rw_lock_t *lock, ulint pass, const char *file_name, ulint line)
UNIV_INLINE ibool rw_lock_x_lock_func_nowait (rw_lock_t *lock, const char *file_name, ulint line)
UNIV_INLINE void rw_lock_s_unlock_func (ulint pass, rw_lock_t *lock)
UNIV_INLINE void rw_lock_x_unlock_func (ulint pass, rw_lock_t *lock)

Variables

UNIV_INLINE ibool const char * file_name
lock last_s_file_name = file_name
lock last_s_line = line

Detailed Description

The read-write lock (for threads)

Created 9/11/1995 Heikki Tuuri

Function Documentation

UNIV_INLINE ibool const char ulint line if ( rw_lock_lock_word_decrlock, 1)

< in: line where requested

UNIV_INTERN void rw_lock_add_debug_info ( rw_lock_t lock,
ulint  pass,
ulint  lock_type,
const char *  file_name,
ulint  line 
)

Inserts the debug information for an rw-lock. in: line where requested

Parameters
lockin: rw-lock
passin: pass value
lock_typein: lock type
file_namein: file where requested
UNIV_INLINE ulint rw_lock_get_reader_count ( const rw_lock_t lock)

Returns the number of readers.

Returns
number of readers
Parameters
lockin: rw-lock
UNIV_INLINE ulint rw_lock_get_waiters ( const rw_lock_t lock)

Check if there are threads waiting for the rw-lock.

Returns
1 if waiters, 0 otherwise
Parameters
lockin: rw-lock
UNIV_INLINE ulint rw_lock_get_writer ( const rw_lock_t lock)

Returns the write-status of the lock - this function made more sense with the old rw_lock implementation.

Returns
RW_LOCK_NOT_LOCKED, RW_LOCK_EX, RW_LOCK_WAIT_EX
Parameters
lockin: rw-lock
UNIV_INLINE ulint rw_lock_get_x_lock_count ( const rw_lock_t lock)

Returns the value of writer_count for the lock. Does not reserve the lock mutex, so the caller must be sure it is not changed during the call.

Returns
value of writer_count
Parameters
lockin: rw-lock
UNIV_INLINE ibool rw_lock_lock_word_decr ( rw_lock_t lock,
ulint  amount 
)

Two different implementations for decrementing the lock_word of a rw_lock: one for systems supporting atomic operations, one for others. This does does not support recusive x-locks: they should be handled by the caller and need not be atomic since they are performed by the current lock holder. Returns true if the decrement was made, false if not.

Returns
TRUE if decr occurs
Parameters
lockin/out: rw-lock
amountin: amount to decrement
UNIV_INLINE lint rw_lock_lock_word_incr ( rw_lock_t lock,
ulint  amount 
)

Increments lock_word the specified amount and returns new value.

Returns
lock->lock_word after increment
Parameters
lockin/out: rw-lock
amountin: amount of increment
UNIV_INTERN void rw_lock_remove_debug_info ( rw_lock_t lock,
ulint  pass,
ulint  lock_type 
)

Removes a debug information struct for an rw-lock. in: lock type

Parameters
lockin: rw-lock
passin: pass value
UNIV_INLINE void rw_lock_reset_waiter_flag ( rw_lock_t lock)

Resets lock->waiters to 0. It is not an error if lock->waiters is already 0. On platforms where ATOMIC builtins are used this function enforces a memory barrier.

Parameters
lockin/out: rw-lock
UNIV_INLINE void rw_lock_s_lock_func ( rw_lock_t lock,
ulint  pass,
const char *  file_name,
ulint  line 
)

NOTE! Use the corresponding macro, not directly this function! Lock an rw-lock in shared mode for the current thread. If the rw-lock is locked in exclusive mode, or there is an exclusive lock request waiting, the function spins a preset time (controlled by SYNC_SPIN_ROUNDS), waiting for the lock, before suspending the thread.

Parameters
lockin: pointer to rw-lock
passin: pass value; != 0, if the lock will be passed to another thread to unlock
file_namein: file name where lock requested
linein: line where requested
UNIV_INLINE ibool rw_lock_s_lock_low ( rw_lock_t lock,
ulint  pass 
)

Low-level function which tries to lock an rw-lock in s-mode. Performs no spinning.

Returns
TRUE if success
Parameters
lockin: pointer to rw-lock
UNIV_INTERN void rw_lock_s_lock_spin ( rw_lock_t lock,
ulint  pass,
const char *  file_name,
ulint  line 
)

Lock an rw-lock in shared mode for the current thread. If the rw-lock is locked in exclusive mode, or there is an exclusive lock request waiting, the function spins a preset time (controlled by SYNC_SPIN_ROUNDS), waiting for the lock before suspending the thread. in: line where requested

Parameters
lockin: pointer to rw-lock
passin: pass value; != 0, if the lock will be passed to another thread to unlock
file_namein: file name where lock requested
UNIV_INLINE void rw_lock_s_unlock_func ( ulint  pass,
rw_lock_t lock 
)

Releases a shared mode lock.

Parameters
passin: pass value; != 0, if the lock may have been passed to another thread to unlock
lockin/out: rw-lock
UNIV_INLINE void rw_lock_set_waiter_flag ( rw_lock_t lock)

Sets lock->waiters to 1. It is not an error if lock->waiters is already

  1. On platforms where ATOMIC builtins are used this function enforces a memory barrier.
Parameters
lockin/out: rw-lock
UNIV_INLINE void rw_lock_set_writer_id_and_recursion_flag ( rw_lock_t lock,
ibool  recursive 
)

This function sets the lock->writer_thread and lock->recursive fields. For platforms where we are using atomic builtins instead of lock->mutex it sets the lock->writer_thread field using atomics to ensure memory ordering. Note that it is assumed that the caller of this function effectively owns the lock i.e.: nobody else is allowed to modify lock->writer_thread at this point in time. The protocol is that lock->writer_thread MUST be updated BEFORE the lock->recursive flag is set.

Parameters
lockin/out: lock to work on
recursivein: TRUE if recursion allowed
UNIV_INLINE ibool rw_lock_x_lock_func_nowait ( rw_lock_t lock,
const char *  file_name,
ulint  line 
)

NOTE! Use the corresponding macro, not directly this function! Lock an rw-lock in exclusive mode for the current thread if the lock can be obtained immediately.

Returns
TRUE if success
Parameters
lockin: pointer to rw-lock
file_namein: file name where lock requested
linein: line where requested
UNIV_INLINE void rw_lock_x_unlock_func ( ulint  pass,
rw_lock_t lock 
)

Releases an exclusive mode lock.

Parameters
passin: pass value; != 0, if the lock may have been passed to another thread to unlock
lockin/out: rw-lock

Variable Documentation

UNIV_INLINE ibool const char* file_name

< in: pass value; != 0, if the lock will be passed to another thread to unlock in: file name where lock requested