### Method

# EDataBook BookSqlite lock

since: 3.12

#### Declaration [src]

    gboolean
    e_book_sqlite_lock (
      EBookSqlite* ebsql,
      EbSqlLockType lock_type,
      GCancellable* cancellable,
      GError** error
    )

#### Description [src]

Obtains an exclusive lock on `ebsql` and starts a transaction.

This should be called if you need to access `ebsql` multiple times while ensuring an atomic transaction. End this transaction with e_book_sqlite_unlock().

If `cancellable` is specified, then `ebsql` will retain a reference to it until `e_book_sqlite_unlock()` is called. Any accesses to `ebsql` with the lock held are expected to have the same `cancellable` specified, or `NULL`.

Aside from ensuring atomicity of transactions, this function will hold a mutex which will cause further calls to `e_book_sqlite_lock()` to block. If you are accessing `ebsql` from multiple threads, then any interactions with `ebsql` should be nested in calls to `e_book_sqlite_lock()` and e_book_sqlite_unlock()..

Available since: 3.12

#### Parameters

`lock_type`

  Type: `EbSqlLockType`

  The `EbSqlLockType` to acquire.

`cancellable`

  Type: `GCancellable`

  A `GCancellable`.

  The argument can be `NULL`.
  The data is owned by the caller of the method.

`error`

  Type: `GError **`

  The return location for a recoverable error.

  The argument can be `NULL`.
  If the return location is not `NULL`, then you must initialize it to a `NULL` `GError*`.
  The argument will be left initialized to `NULL` by the method if there are no errors.
  In case of error, the argument will be set to a newly allocated `GError`; the caller will take ownership of the data, and be responsible for freeing it.

#### Return value

Type: `gboolean`

`TRUE` on success, otherwise `FALSE` is returned and `error` is set appropriately.