- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有多个线程在 GHashTable 中添加、修改和查找数据。是线程安全的,还是需要自己实现线程安全?
最佳答案
The documentation很清楚地说明了这一点:
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.
所以:不,哈希表不是线程安全的。
关于c - GHashTable (glib2) 线程安全吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8837822/
g_hash_table_new() 的文档表示 Hash values are used to determine where keys are stored within the GHashTab
以下是我可以创建的问题的最短可编译演示。 查看接近尾声的 printf 调用,输出如下。我不知道为什么两个完全相同的语句可以做到这一点。它可能与输入类型有关,但我看不出它可能是什么。 #include
你好,考虑到没有 gdouble_to_pointer 方法,我想知道是否可以将 double 存储到 ghashtable 中。我正在学习 IBM 在线找到的教程 http://www.ibm.co
在我的应用程序中,我需要保存一个 Glib GHashTable 实例写入磁盘,稍后加载到内存。但是我找不到任何方法直接转储实例。 一个选项是不直接保存GHashTable,而是一个接一个的保存ent
所以基本上我想将我的静音/取消静音通话与通话地点隔离。 我做了一个方法:void janus_audiobridge_mute_toggle_participants(janus_audiobridg
这是我的用例:我想使用 glib's GHashTable并使用 IP 地址作为键,并将此 IP 地址发送/接收的数据量作为值。例如,我成功地使用一些内核变量在用户空间中实现了整个问题,以便查看每个
我正在使用 glib 中的 GHashTable,我想通过键删除一个键值对。如 docs 中所述当调用 g_hash_table_remove() 时,您需要在动态分配时自行释放键和值。但是我如何获得
我有多个线程在 GHashTable 中添加、修改和查找数据。是线程安全的,还是需要自己实现线程安全? 最佳答案 The documentation很清楚地说明了这一点: After calling
我正在尝试以干净的方式打印 GDB 中的 GHashTable。我发现了一个关于 Archer 项目的博客,它展示了很好地打印 GHashTable 的能力: http://blogs.gnome.o
您好,这个问题与 GLib、gpointer 相关。 我创建了一个 gpointer 类型的值。 gpointer keys; 我调用了一个函数 insert_data(gpoi
我正在研究GHashTable。虽然 Stackoverflow 中已经有一些示例,但它们只是一些常见的情况。所以我仍然不确定如何实现我的要求并决定寻求帮助。 我想使用 uint64_t 作为键,使用
我的问题与 GLib、C 编程有关。当我初始化结构 GHashtable 时。 struct _GHashTable { gint size; gint
我正在尝试将字符串映射到 GArrays使用GHashTable 。到目前为止,我还没有成功。 我像这样声明哈希表: hash_table = g_hash_table_new_full(g_str_
编译器说 GHashTable 未定义,但如果我在从数组检索 GHashTable 的代码上方使用它,则显然它已定义。到底是怎么回事?我很困惑。 gcc -Wall -o tht `pkg-confi
我正在尝试序列化和反序列化 GHashTable JSON 和 valgrind 的输入和输出报告说这样做的结果肯定会丢失内存。 g_hash_table_new 有抑制在 glib.suppress
给出代码片段: #include #include void print_city(gpointer value, gpointer data) { printf("%s, ", valu
有没有人同时使用过 GHashTable 和 std::tr1::unordered_map?我想知道使用哪一种,更推荐哪一种。我在网上找不到任何真正有用的东西。 谢谢, 最佳答案 当标准库容器和工具
我想放一个GSList在 GHashTable 里面,这是我管理所有这些的方式: #include #include typedef struct Foo_ { GHashTable * ba
我想在程序初始化时创建一个 GHashTable,稍后仅供新创建的线程读取并发访问。 在没有锁的情况下这样做安全吗? 最佳答案 一般来说,只有当您可以在另一个线程中读取或修改数据的同时修改数据时,才需
我正在尝试遍历我的哈希表并将键和值存储到一个结构数组中。我不断遇到段错误。我猜是由于基于指针的结构。 当我应该使用指向结构的指针和结构数组时,我仍然感到困惑。 编辑:让它工作。请参阅下面的答案。 最佳
我是一名优秀的程序员,十分优秀!