thread-safe functions in fchash.c
This commit is contained in:
parent
4758144492
commit
1b2279d6b5
|
@ -169,13 +169,15 @@ FcHashTableAdd (FcHashTable *table,
|
||||||
|
|
||||||
return !ret;
|
return !ret;
|
||||||
}
|
}
|
||||||
|
retry:
|
||||||
for (prev = &table->buckets[hash % FC_HASH_SIZE];
|
for (prev = &table->buckets[hash % FC_HASH_SIZE];
|
||||||
(b = *prev); prev = &(b->next))
|
(b = fc_atomic_ptr_get (prev)); prev = &(b->next))
|
||||||
{
|
{
|
||||||
if (!table->compare_func (bucket->key, key))
|
if (!table->compare_func (bucket->key, key))
|
||||||
goto destroy;
|
goto destroy;
|
||||||
}
|
}
|
||||||
*prev = bucket;
|
if (!fc_atomic_ptr_cmpexch (prev, b, bucket))
|
||||||
|
goto retry;
|
||||||
|
|
||||||
return FcTrue;
|
return FcTrue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue