Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
3b56c119
提交
3b56c119
authored
3月 22, 2011
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-3173
上级
fd608901
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
112 行增加
和
1 行删除
+112
-1
switch_apr.h
src/include/switch_apr.h
+60
-0
switch_apr.c
src/switch_apr.c
+52
-1
没有找到文件。
src/include/switch_apr.h
浏览文件 @
3b56c119
...
...
@@ -24,6 +24,7 @@
* Contributor(s):
*
* Anthony Minessale II <anthm@freeswitch.org>
* Eliot Gable <egable@gmail.com>
*
* switch_apr.h -- APR includes header
*
...
...
@@ -410,6 +411,65 @@ SWITCH_DECLARE(switch_status_t) switch_mutex_trylock(switch_mutex_t *lock);
/** @} */
/**
* @defgroup switch_atomic Multi-Threaded Adtomic Operations Routines
* @ingroup switch_apr
* @{
*/
/** Opaque type used for the atomic operations */
#ifdef apr_atomic_t
typedef
apr_atomic_t
switch_atomic_t
;
#else
typedef
uint32_t
switch_atomic_t
;
#endif
/**
* Some architectures require atomic operations internal structures to be
* initialized before use.
* @param pool The memory pool to use when initializing the structures.
*/
SWITCH_DECLARE
(
switch_status_t
)
switch_atomic_init
(
switch_memory_pool_t
*
pool
);
/**
* Uses an atomic operation to read the uint32 value at the location specified
* by mem.
* @param mem The location of memory which stores the value to read.
*/
SWITCH_DECLARE
(
uint32_t
)
switch_atomic_read
(
volatile
switch_atomic_t
*
mem
);
/**
* Uses an atomic operation to set a uint32 value at a specified location of
* memory.
* @param mem The location of memory to set.
* @param val The uint32 value to set at the memory location.
*/
SWITCH_DECLARE
(
void
)
switch_atomic_set
(
volatile
switch_atomic_t
*
mem
,
uint32_t
val
);
/**
* Uses an atomic operation to add the uint32 value to the value at the
* specified location of memory.
* @param mem The location of the value to add to.
* @param val The uint32 value to add to the value at the memory location.
*/
SWITCH_DECLARE
(
void
)
switch_atomic_add
(
volatile
switch_atomic_t
*
mem
,
uint32_t
val
);
/**
* Uses an atomic operation to increment the value at the specified memroy
* location.
* @param mem The location of the value to increment.
*/
SWITCH_DECLARE
(
void
)
switch_atomic_inc
(
volatile
switch_atomic_t
*
mem
);
/**
* Uses an atomic operation to decrement the value at the specified memroy
* location.
* @param mem The location of the value to decrement.
*/
SWITCH_DECLARE
(
int
)
switch_atomic_dec
(
volatile
switch_atomic_t
*
mem
);
/** @} */
/**
* @defgroup switch_thread_rwlock Thread Read/Write lock Routines
* @ingroup switch_apr
...
...
src/switch_apr.c
浏览文件 @
3b56c119
...
...
@@ -24,7 +24,7 @@
* Contributor(s):
*
* Michael Jerris <mike@jerris.com>
*
*
Eliot Gable <egable@gmail.com>
*
* switch_apr.c -- apr wrappers and extensions
*
...
...
@@ -38,6 +38,7 @@
/* apr headers*/
#include <apr.h>
#include <apr_atomic.h>
#include <apr_pools.h>
#include <apr_hash.h>
#include <apr_network_io.h>
...
...
@@ -1141,6 +1142,56 @@ SWITCH_DECLARE(switch_status_t) switch_thread_join(switch_status_t *retval, swit
}
SWITCH_DECLARE
(
switch_status_t
)
switch_atomic_init
(
switch_memory_pool_t
*
pool
)
{
return
apr_atomic_init
((
apr_pool_t
*
)
pool
);
}
SWITCH_DECLARE
(
uint32_t
)
switch_atomic_read
(
volatile
switch_atomic_t
*
mem
)
{
#ifdef apr_atomic_t
return
apr_atomic_read
((
apr_atomic_t
*
)
mem
);
#else
return
apr_atomic_read32
((
apr_uint32_t
*
)
mem
);
#endif
}
SWITCH_DECLARE
(
void
)
switch_atomic_set
(
volatile
switch_atomic_t
*
mem
,
uint32_t
val
)
{
#ifdef apr_atomic_t
apr_atomic_set
((
apr_atomic_t
*
)
mem
,
val
);
#else
apr_atomic_set32
((
apr_uint32_t
*
)
mem
,
val
);
#endif
}
SWITCH_DECLARE
(
void
)
switch_atomic_add
(
volatile
switch_atomic_t
*
mem
,
uint32_t
val
)
{
#ifdef apr_atomic_t
apr_atomic_add
((
apr_atomic_t
*
)
mem
,
val
);
#else
apr_atomic_add32
((
apr_uint32_t
*
)
mem
,
val
);
#endif
}
SWITCH_DECLARE
(
void
)
switch_atomic_inc
(
volatile
switch_atomic_t
*
mem
)
{
#ifdef apr_atomic_t
apr_atomic_inc
((
apr_atomic_t
*
)
mem
);
#else
apr_atomic_inc32
((
apr_uint32_t
*
)
mem
);
#endif
}
SWITCH_DECLARE
(
int
)
switch_atomic_dec
(
volatile
switch_atomic_t
*
mem
)
{
#ifdef apr_atomic_t
return
apr_atomic_dec
((
apr_atomic_t
*
)
mem
);
#else
return
apr_atomic_dec32
((
apr_uint32_t
*
)
mem
);
#endif
}
/* For Emacs:
* Local Variables:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论