Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
fbcb8622
提交
fbcb8622
authored
5月 24, 2012
作者:
Tamas Cseke
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add thread safe hash multi delete function and make callback optional
上级
f37b1f0c
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
57 行增加
和
3 行删除
+57
-3
switch_core.h
src/include/switch_core.h
+21
-1
switch_core_hash.c
src/switch_core_hash.c
+36
-2
没有找到文件。
src/include/switch_core.h
浏览文件 @
fbcb8622
...
...
@@ -1277,7 +1277,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_locked(_In_ switch_hash_
\brief Delete data from a hash based on desired key
\param hash the hash to delete from
\param key the key from which to delete the data
\param
mutex
optional rwlock to wrlock
\param
rwlock
optional rwlock to wrlock
\return SWITCH_STATUS_SUCCESS if the data is deleted
*/
SWITCH_DECLARE
(
switch_status_t
)
switch_core_hash_delete_wrlock
(
_In_
switch_hash_t
*
hash
,
_In_z_
const
char
*
key
,
_In_opt_
switch_thread_rwlock_t
*
rwlock
);
...
...
@@ -1290,6 +1290,26 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_wrlock(_In_ switch_hash_
*/
SWITCH_DECLARE
(
switch_status_t
)
switch_core_hash_delete_multi
(
_In_
switch_hash_t
*
hash
,
_In_
switch_hash_delete_callback_t
callback
,
_In_opt_
void
*
pData
);
/*!
\brief Delete data from a hash based on callback function
\param hash the hash to delete from
\param callback the function to call which returns SWITCH_TRUE to delete, SWITCH_FALSE to preserve
\param rwlock optional rwlock to wrlock
\return SWITCH_STATUS_SUCCESS if any data is deleted
*/
SWITCH_DECLARE
(
switch_status_t
)
switch_core_hash_delete_multi_wrlock
(
_In_
switch_hash_t
*
hash
,
_In_
switch_hash_delete_callback_t
callback
,
_In_opt_
void
*
pData
,
_In_
switch_thread_rwlock_t
*
rwlock
);
/*!
\brief Delete data from a hash based on callback function
\param hash the hash to delete from
\param callback the function to call which returns SWITCH_TRUE to delete, SWITCH_FALSE to preserve
\param mutex optional mutex to lock
\return SWITCH_STATUS_SUCCESS if any data is deleted
*/
SWITCH_DECLARE
(
switch_status_t
)
switch_core_hash_delete_multi_locked
(
_In_
switch_hash_t
*
hash
,
_In_
switch_hash_delete_callback_t
callback
,
_In_opt_
void
*
pData
,
_In_
switch_mutex_t
*
mutex
);
/*!
\brief Retrieve data from a given hash
\param hash the hash to retrieve from
...
...
src/switch_core_hash.c
浏览文件 @
fbcb8622
...
...
@@ -157,7 +157,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_multi(switch_hash_t *has
switch_event_create_subclass
(
&
event
,
SWITCH_EVENT_CLONE
,
NULL
);
switch_assert
(
event
);
/* iterate through the hash, call callback, if callback returns true, put the key on the list (event)
/* iterate through the hash, call callback, if callback
is NULL or
returns true, put the key on the list (event)
When done, iterate through the list deleting hash entries
*/
...
...
@@ -165,7 +165,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_multi(switch_hash_t *has
const
void
*
key
;
void
*
val
;
switch_hash_this
(
hi
,
&
key
,
NULL
,
&
val
);
if
(
callback
(
key
,
val
,
pData
))
{
if
(
!
callback
||
callback
(
key
,
val
,
pData
))
{
switch_event_add_header_string
(
event
,
SWITCH_STACK_BOTTOM
,
"delete"
,
(
const
char
*
)
key
);
}
}
...
...
@@ -182,6 +182,40 @@ SWITCH_DECLARE(switch_status_t) switch_core_hash_delete_multi(switch_hash_t *has
return
status
;
}
SWITCH_DECLARE
(
switch_status_t
)
switch_core_hash_delete_multi_wrlock
(
switch_hash_t
*
hash
,
switch_hash_delete_callback_t
callback
,
void
*
pData
,
switch_thread_rwlock_t
*
rwlock
)
{
switch_status_t
status
=
SWITCH_STATUS_SUCCESS
;
if
(
rwlock
)
{
switch_thread_rwlock_wrlock
(
rwlock
);
}
status
=
switch_core_hash_delete_multi
(
hash
,
callback
,
pData
);
if
(
rwlock
)
{
switch_thread_rwlock_unlock
(
rwlock
);
}
return
status
;
}
SWITCH_DECLARE
(
switch_status_t
)
switch_core_hash_delete_multi_locked
(
switch_hash_t
*
hash
,
switch_hash_delete_callback_t
callback
,
void
*
pData
,
switch_mutex_t
*
mutex
)
{
switch_status_t
status
=
SWITCH_STATUS_SUCCESS
;
if
(
mutex
)
{
switch_mutex_lock
(
mutex
);
}
status
=
switch_core_hash_delete_multi
(
hash
,
callback
,
pData
);
if
(
mutex
)
{
switch_mutex_unlock
(
mutex
);
}
return
status
;
}
SWITCH_DECLARE
(
void
*
)
switch_core_hash_find
(
switch_hash_t
*
hash
,
const
char
*
key
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论