int cp_heap_txunlock(cp_heap *heap) { if (heap->mode & COLLECTION_MODE_NOSYNC) return 0; if (heap->mode & COLLECTION_MODE_IN_TRANSACTION) { cp_thread self = cp_thread_self(); if (cp_thread_equal(self, heap->txowner)) return 0; } return cp_mutex_unlock(heap->lock); }
int cp_avltree_txunlock(cp_avltree *tree) { if (tree->mode & COLLECTION_MODE_NOSYNC) return 0; if (tree->mode & COLLECTION_MODE_IN_TRANSACTION && tree->txtype == COLLECTION_LOCK_WRITE) { cp_thread self = cp_thread_self(); if (cp_thread_equal(self, tree->transaction_owner)) return 0; } return cp_avltree_unlock_internal(tree); }
int cp_avltree_txlock(cp_avltree *tree, int type) { /* clear errno to allow client code to distinguish between a NULL return * value indicating the tree doesn't contain the requested value and NULL * on locking failure in tree operations */ errno = 0; if (tree->mode & COLLECTION_MODE_NOSYNC) return 0; if (tree->mode & COLLECTION_MODE_IN_TRANSACTION && tree->txtype == COLLECTION_LOCK_WRITE) { cp_thread self = cp_thread_self(); if (cp_thread_equal(self, tree->transaction_owner)) return 0; } return cp_avltree_lock_internal(tree, type); }