DbEnv::lock_get |
#include <db_cxx.h>int DbEnv::lock_get(u_int32_t locker, u_int32_t flags, const Dbt *obj, const db_lockmode_t lock_mode, DbLock *lock);
The DbEnv::lock_get method acquires a lock from the lock table, returning information about it in the lock argument.
The locker argument specified to DbEnv::lock_get is an unsigned 32-bit integer quantity. It represents the entity requesting or releasing the lock.
The flags value must be set to 0 or the following value:
The obj argument is an untyped byte string that specifies the object to be locked or released. Applications using the locking subsystem directly while also doing locking via the Berkeley DB access methods must take care not to inadvertently lock objects that happen to be equal to the unique file IDs used to lock files. See Access method locking conventions for more information.
The mode argument is used as an index into the environment's lock conflict matrix. When using the default lock conflict matrix, mode must be set to one of the following values:
See DbEnv::set_lk_conflicts and Standard Lock Modes for more information on the lock conflict matrix.
If a lock is requested that cannot be immediately granted, and the flags parameter was set to DB_LOCK_NOWAIT, the DbEnv::lock_get method may return or throw an exception encapsulating DB_LOCK_NOTGRANTED.
Otherwise, the DbEnv::lock_get method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success.
The DbEnv::lock_get method may fail and throw an exception or return a non-zero error for the following conditions:
The DbEnv::lock_get method may fail and throw an exception or return a non-zero error for errors specified for other Berkeley DB and C library or system methods. If a catastrophic error has occurred, the DbEnv::lock_get method may fail and either return DB_RUNRECOVERY or throw an exception encapsulating DB_RUNRECOVERY, in which case all subsequent Berkeley DB calls will fail in the same way.