I have multiple threads adding, modifying and looking up data in GHashTable. Is it threadsafe, or do I need to implement threadsafety myself?
Is GHashTable (glib2) thread safe?
Asked Answered
why someone would vote up this question as too localized ? This is good, reasonable and fair question. –
Germanism
The documentation states this pretty clearly:
After calling
g_thread_init()
, GLib is completely thread safe (all global data is automatically locked), but individual data structure instances are not automatically locked for performance reasons. So, for example you must coordinate accesses to the sameGHashTable
from multiple threads.
So: no, the hash table is not thread safe.
© 2022 - 2024 — McMap. All rights reserved.