[Mesa-dev] [PATCH 10/13] hash: Add _mesa_HashRemoveLocked() function.

Timothy Arceri t_arceri at yahoo.com.au
Fri Aug 7 01:57:01 PDT 2015


On Thu, 2015-08-06 at 17:11 -0700, Matt Turner wrote:
> ---
>  src/mesa/main/hash.c | 19 +++++++++++++++----
>  src/mesa/main/hash.h |  2 ++
>  2 files changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c
> index 315b5d6..aa1c6a1 100644
> --- a/src/mesa/main/hash.c
> +++ b/src/mesa/main/hash.c
> @@ -328,8 +328,8 @@ _mesa_HashInsert(struct _mesa_HashTable *table, GLuint 
> key, void *data)
>   * While holding the hash table's lock, searches the entry with the 
> matching
>   * key and unlinks it.
>   */
> -void
> -_mesa_HashRemove(struct _mesa_HashTable *table, GLuint key)
> +static inline void
> +_mesa_HashRemove_unlocked(struct _mesa_HashTable *table, GLuint key)

Any reason why this isnt just _mesa_HashRemoveUnlocked to match the naming of
locked?


>  {
>     struct hash_entry *entry;
>  
> @@ -343,17 +343,28 @@ _mesa_HashRemove(struct _mesa_HashTable *table, GLuint 
> key)
>        return;
>     }
>  
> -   mtx_lock(&table->Mutex);
>     if (key == DELETED_KEY_VALUE) {
>        table->deleted_key_data = NULL;
>     } else {
>        entry = _mesa_hash_table_search(table->ht, uint_key(key));
>        _mesa_hash_table_remove(table->ht, entry);
>     }
> -   mtx_unlock(&table->Mutex);
>  }
>  
>  
> +void
> +_mesa_HashRemoveLocked(struct _mesa_HashTable *table, GLuint key)
> +{
> +   _mesa_HashRemove_unlocked(table, key);
> +}
> +
> +void
> +_mesa_HashRemove(struct _mesa_HashTable *table, GLuint key)
> +{
> +   mtx_lock(&table->Mutex);
> +   _mesa_HashRemove_unlocked(table, key);
> +   mtx_unlock(&table->Mutex);
> +}
>  
>  /**
>   * Delete all entries in a hash table, but don't delete the table itself.
> diff --git a/src/mesa/main/hash.h b/src/mesa/main/hash.h
> index da3b997..52a6c5d 100644
> --- a/src/mesa/main/hash.h
> +++ b/src/mesa/main/hash.h
> @@ -54,6 +54,8 @@ extern void *_mesa_HashLookupLocked(struct _mesa_HashTable 
> *table, GLuint key);
>  extern void _mesa_HashInsertLocked(struct _mesa_HashTable *table,
>                                     GLuint key, void *data);
>  
> +extern void _mesa_HashRemoveLocked(struct _mesa_HashTable *table, GLuint 
> key);
> +
>  extern void
>  _mesa_HashDeleteAll(struct _mesa_HashTable *table,
>                      void (*callback)(GLuint key, void *data, void 
> *userData),


More information about the mesa-dev mailing list