Reference Guide C API www.spreadconcepts.com


C API
Replicated Hash Table
Version 2.0


rht_grab
  rht_code rht_grab(rht r, int flags);


Parameters
  r replica handle of replica to lock
  flags RHT_DIRTY_READ (default) or RHT_CLEAN_READ


Return Values
  0 on success
  non-zero for error


Description
 

rht_grab acquires a recursive lock on the replica, blocking all other threads from reading and/or writing any portion of the replica.

For example, this will block other threads that attempt to call even rht_error on the locked replica. For each successful call to rht_grab a thread must call rht_drop to release the lock.

Locks should not be held for long because updates from other replicas will build up in memory waiting to be applied. This can lead to out of memory conditions or communication failures, which will cause the replica to permanently fail.

Note that during callbacks the executing thread has a lock on the replica upon entry into the callback. This lock should never be dropped during the callback. If it is, undefined behavior will occur.

Use of the default RHT_DIRTY_READ flag will cause rht_grab to lock immediately without waiting for any locally generated updates to be applied. Whereas, specifying the RHT_CLEAN_READ will first apply all locally generated updates, and then attempt to grab a lock on the replica.



Requirements
  Header: Declared in rht.h
Library: Use rht.lib
Version: 2.0


Also See
  RHT reference guide, local lock operations


Copyright © 2004, Spread Concepts LLC, All rights reserved