refactor: move locking responsibility to user
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Jef Roosens 2022-12-07 11:28:20 +01:00
parent 2a373f3841
commit 088322c18f
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
6 changed files with 100 additions and 88 deletions

View file

@ -94,7 +94,8 @@ bool trie_add_no_lock(Trie *trie, const char *key, Entry *entry);
* @param trie
* @param entry entry to add
* @param secure whether to generate a longer, more secure random key
* @return the generated key
* @return pointer to the generated key. This pointer is safe to use after
* unlocking the trie, and should be freed manually.
*/
char *trie_add_random(Trie *trie, Entry *entry, bool secure);
@ -116,4 +117,28 @@ bool trie_remove(Trie *trie, const char *key);
*/
size_t trie_size(Trie *trie);
/*
* Acquire a read lock on the trie.
*
* @return 0 if successful, non-zero otherwise (return value of
* pthread_rwlock_rdlock)
*/
int trie_rlock(Trie *trie);
/*
* Acquire a write lock on the trie.
*
* @return 0 if successful, non-zero otherwise (return value of
* pthread_rwlock_wrlock)
*/
int trie_wlock(Trie *trie);
/*
* Release the lock on a trie after having acquired it beforehand.
*
* @return 0 if successful, non-zero otherwise (return value of
* pthread_rwlock_unlock)
*/
int trie_unlock(Trie *trie);
#endif // AD3_TERNARYTRIE