#include <sm_vas.h> // which includes sm.h static rc_t lock( const lvid_t& lvid, lock_mode_t mode, lock_duration_t duration = t_long, long timeout = WAIT_SPECIFIED_BY_XCT); static rc_t lock( const lvid_t& lvid, const serial_t& serial, lock_mode_t mode, lock_duration_t duration = t_long, long timeout = WAIT_SPECIFIED_BY_XCT); static rc_t unlock( const lvid_t& lvid, const serial_t& serial); static rc_t query_lock( const lvid_t& lvid, const serial_t& serial, lock_mode_t& mode, bool implicit = FALSE); static rc_t set_lock_cache_enable(bool enable); static rc_t lock_cache_enabled(bool& enabled); static rc_t set_escalation_thresholds( int4 toPage, int4 toStore, int4 toVolume); static rc_t get_escalation_thresholds( int4& toPage, int4& toStore, int4& toVolume); static rc_t dont_escalate( const lockid_t& n, bool passOnToDescendants = true); static rc_t dont_escalate( const lvid_t& lvid, const serial_t& serial, bool passOnToDescendants = true); static rc_t dont_escalate( const lvid_t& lvid, bool passOnToDescendants = true);
Locks are acquired implicitly by many ss_m methods. For those situations where more precise control of locking is desired, the following methods allow explicit locking and unlocking.
lock(lvid, mode, duration, timeout)
lock(lvid, serial, mode, duration, timeout)
Each transaction has a cache of recently acquired locks The following methods control the use of the cache. These are not supported methods and may be removed in later versions of the software. Note: that the methods only affect the transaction associated with the current thread.
set_lock_cache_enable(enable)
The lock manager will escalate from a record lock to a page lock, from a page lock to a store lock, and from a store lock to a volume lock, to reduce the number of locks in the table. You can control the thresholds for escalation throught the methods get_escalation_thresholds and set_escalation_thresholds. The default values are as follows:
When escalation is in use, it be prevented on selected volumes or other lock-able objects through the three don_escalate methods. If the argument passOnToDescendantsis false, locks acquired on objects below the volume (or given lockid) in the lock hierarchy will still be escalated according to the thresholds.