"Using Core-Tech MDBM Handle Pool in your application"

Properties wishing to use mdbm in multi-threaded applications must make sure each thread uses a unique handle to carry out db operations.

There are two changes that are required to use this library:

1] Create an mdbm handle pool by duplicating your original mdbm handle

// open mdbm file
if ((db = mdbm_open(fn, flags, 0, 0, 0)) == NULL)
return;
// create the mdbm handle pool
if ((pool = mdbm_pool_create_pool(db, pool_size, NULL)) == NULL) {
return;
}

2] Obtain a unique handle in your thread for your db operation

// get mdbm handle from the pool
if ((dbh = mdbm_pool_acquire_handle(pool, NULL)) == NULL)
return;
// lock the mdbm handle
if (mdbm_lock(dbh) != 1) {
mdbm_pool_release_handle(pool, dbh, NULL);
return;
}
// carry out your mdbm operations ...
// unlock and return the handle to the pool
mdbm_pool_release_handle(pool, dbh, NULL);