[Mesa-dev] [PATCH 1/2] mesa: create locked version of HashWalk
Timothy Arceri
tarceri at itsqueeze.com
Mon Apr 24 10:31:29 UTC 2017
On 24/04/17 16:15, Michael Schellenberger Costa wrote:
> Him Tim,
>
> I hadnt had my morning coffee butdidnt you do it the other way around?
>
> It looks like, that "_mesa_HashWalk" ist he locked and "_mesa_HashWalkLocked" the unlocked version.
Yeah that's just the naming convention. It's a little confusing I agree
but that's they way it works with the other functions.
>
> Michael
>
> -----Ursprüngliche Nachricht-----
> Von: mesa-dev [mailto:mesa-dev-bounces at lists.freedesktop.org] Im Auftrag von Timothy Arceri
> Gesendet: Montag, 24. April 2017 07:59
> An: mesa-dev at lists.freedesktop.org
> Cc: Timothy Arceri <tarceri at itsqueeze.com>
> Betreff: [Mesa-dev] [PATCH 1/2] mesa: create locked version of HashWalk
>
> ---
> src/mesa/main/hash.c | 34 ++++++++++++++++++++++++++--------
> src/mesa/main/hash.h | 5 +++++
> 2 files changed, 31 insertions(+), 8 deletions(-)
>
> diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c index b7a7bd9..a3772bd 100644
> --- a/src/mesa/main/hash.c
> +++ b/src/mesa/main/hash.c
> @@ -404,40 +404,58 @@ _mesa_HashDeleteAll(struct _mesa_HashTable *table, }
>
>
> /**
> * Walk over all entries in a hash table, calling callback function for each.
> * \param table the hash table to walk
> * \param callback the callback function
> * \param userData arbitrary pointer to pass along to the callback
> * (this is typically a struct gl_context pointer)
> */
> +static void
> +hash_walk_unlocked(const struct _mesa_HashTable *table,
> + void (*callback)(GLuint key, void *data, void *userData),
> + void *userData)
> +{
> + assert(table);
> + assert(callback);
> +
> + struct hash_entry *entry;
> + hash_table_foreach(table->ht, entry) {
> + callback((uintptr_t)entry->key, entry->data, userData);
> + }
> + if (table->deleted_key_data)
> + callback(DELETED_KEY_VALUE, table->deleted_key_data, userData); }
> +
> +
> void
> _mesa_HashWalk(const struct _mesa_HashTable *table,
> void (*callback)(GLuint key, void *data, void *userData),
> void *userData)
> {
> /* cast-away const */
> struct _mesa_HashTable *table2 = (struct _mesa_HashTable *) table;
> - struct hash_entry *entry;
>
> - assert(table);
> - assert(callback);
> mtx_lock(&table2->Mutex);
> - hash_table_foreach(table->ht, entry) {
> - callback((uintptr_t)entry->key, entry->data, userData);
> - }
> - if (table->deleted_key_data)
> - callback(DELETED_KEY_VALUE, table->deleted_key_data, userData);
> + hash_walk_unlocked(table, callback, userData);
> mtx_unlock(&table2->Mutex);
> }
>
> +void
> +_mesa_HashWalkLocked(const struct _mesa_HashTable *table,
> + void (*callback)(GLuint key, void *data, void *userData),
> + void *userData)
> +{
> + hash_walk_unlocked(table, callback, userData); }
> +
> static void
> debug_print_entry(GLuint key, void *data, void *userData) {
> _mesa_debug(NULL, "%u %p\n", key, data); }
>
> /**
> * Dump contents of hash table for debugging.
> *
> * \param table the hash table.
> diff --git a/src/mesa/main/hash.h b/src/mesa/main/hash.h index 52a6c5d..9eb0f0e 100644
> --- a/src/mesa/main/hash.h
> +++ b/src/mesa/main/hash.h
> @@ -59,20 +59,25 @@ 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),
> void *userData);
>
> extern void
> _mesa_HashWalk(const struct _mesa_HashTable *table,
> void (*callback)(GLuint key, void *data, void *userData),
> void *userData);
>
> +extern void
> +_mesa_HashWalkLocked(const struct _mesa_HashTable *table,
> + void (*callback)(GLuint key, void *data, void *userData),
> + void *userData);
> +
> extern void _mesa_HashPrint(const struct _mesa_HashTable *table);
>
> extern GLuint _mesa_HashFindFreeKeyBlock(struct _mesa_HashTable *table, GLuint numKeys);
>
> extern GLuint
> _mesa_HashNumEntries(const struct _mesa_HashTable *table);
>
> extern void _mesa_test_hash_functions(void);
>
>
> --
> 2.9.3
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
More information about the mesa-dev
mailing list