aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/hash.c
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2017-04-24 15:59:23 +1000
committerTimothy Arceri <[email protected]>2017-04-25 09:58:39 +1000
commita82d6a307d0cfc1e4434bbecb1b308b94b1ca462 (patch)
treec2c6dd52e59ec1992afe0fd4c93b8ebc94456d5e /src/mesa/main/hash.c
parent6a40ccec4b232fc04edd9eb3c047f949e4422612 (diff)
mesa: create locked version of HashWalk
Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/mesa/main/hash.c')
-rw-r--r--src/mesa/main/hash.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/mesa/main/hash.c b/src/mesa/main/hash.c
index b7a7bd9f648..a3772bdfb58 100644
--- a/src/mesa/main/hash.c
+++ b/src/mesa/main/hash.c
@@ -411,6 +411,23 @@ _mesa_HashDeleteAll(struct _mesa_HashTable *table,
* \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),
@@ -418,19 +435,20 @@ _mesa_HashWalk(const struct _mesa_HashTable *table,
{
/* 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)
{