2016-07-29 16:43:46 +08:00
|
|
|
|
#ifndef ACL_ATOMIC_INCLUDE_H
|
|
|
|
|
#define ACL_ATOMIC_INCLUDE_H
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C"
|
|
|
|
|
{
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "acl_define.h"
|
|
|
|
|
|
|
|
|
|
typedef struct ACL_ATOMIC ACL_ATOMIC;
|
|
|
|
|
|
2017-08-13 22:41:35 +08:00
|
|
|
|
/**
|
2017-08-13 22:53:52 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {ACL_ATOMIC*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>´<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD>
|
2017-08-13 22:41:35 +08:00
|
|
|
|
*/
|
2016-07-29 16:43:46 +08:00
|
|
|
|
ACL_API ACL_ATOMIC *acl_atomic_new(void);
|
2017-08-13 22:41:35 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2017-08-13 22:53:52 +08:00
|
|
|
|
* <EFBFBD>ͷ<EFBFBD>ԭ<EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param self {ACL_ATOMIC*} ԭ<EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD>
|
2017-08-13 22:41:35 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API void acl_atomic_free(ACL_ATOMIC *self);
|
|
|
|
|
|
|
|
|
|
/**
|
2017-08-13 22:53:52 +08:00
|
|
|
|
* <EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD>ڶԸö<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD>Ӳ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param self {ACL_ATOMIC*} ԭ<EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param value {void*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD>ԭ<EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ֶԸö<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD>Ӳ<EFBFBD><EFBFBD><EFBFBD>
|
2017-08-13 22:41:35 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API void acl_atomic_set(ACL_ATOMIC *self, void *value);
|
|
|
|
|
|
|
|
|
|
/**
|
2017-08-13 22:53:52 +08:00
|
|
|
|
* <EFBFBD>Ƚϲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƚ϶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮ǰ<EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param self {ACL_ATOMIC*} ԭ<EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param cmp {void*} <EFBFBD><EFBFBD><EFBFBD>Ƚ϶<EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param value {void*} <EFBFBD><EFBFBD>ԭ<EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƚ϶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬʱ<EFBFBD>Ὣ<EFBFBD>ö<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {void*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ<EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD>֮ǰ<EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD>
|
2017-08-13 22:41:35 +08:00
|
|
|
|
*/
|
2016-07-29 16:43:46 +08:00
|
|
|
|
ACL_API void *acl_atomic_cas(ACL_ATOMIC *self, void *cmp, void *value);
|
2017-08-13 22:41:35 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2017-08-13 22:53:52 +08:00
|
|
|
|
* <EFBFBD><EFBFBD>ԭ<EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>а<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮ǰ<EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param self {ACL_ATOMIC*} ԭ<EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param value {void*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {void*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮ǰ<EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD>
|
2017-08-13 22:41:35 +08:00
|
|
|
|
*/
|
2016-07-29 16:43:46 +08:00
|
|
|
|
ACL_API void *acl_atomic_xchg(ACL_ATOMIC *self, void *value);
|
2017-08-13 22:41:35 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2017-08-13 22:53:52 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> acl_atomic_set <EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD><EFBFBD>ô˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* <EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
* @param self {ACL_ATOMIC*} ԭ<EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param n {long long} <EFBFBD><EFBFBD>ԭ<EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵΪ<EFBFBD><EFBFBD>ֵ
|
2017-08-13 22:41:35 +08:00
|
|
|
|
*/
|
2017-06-22 12:21:54 +08:00
|
|
|
|
ACL_API void acl_atomic_int64_set(ACL_ATOMIC *self, long long n);
|
2017-08-13 22:41:35 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2017-08-13 22:53:52 +08:00
|
|
|
|
* <EFBFBD>Ȼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>洢<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD>Ȼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>洢<EFBFBD>ڸ<EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param self {ACL_ATOMIC*} ԭ<EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param n {long long} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
* @return {long long} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
2017-08-13 22:41:35 +08:00
|
|
|
|
*/
|
2017-06-22 11:03:07 +08:00
|
|
|
|
ACL_API long long acl_atomic_int64_fetch_add(ACL_ATOMIC *self, long long n);
|
2017-08-13 22:41:35 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2017-08-13 22:53:52 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>洢<EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ؽ<EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
* @param self {ACL_ATOMIC*} ԭ<EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param n {long long} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
* @return {long long} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
2017-08-13 22:41:35 +08:00
|
|
|
|
*/
|
2017-06-22 11:03:07 +08:00
|
|
|
|
ACL_API long long acl_atomic_int64_add_fetch(ACL_ATOMIC *self, long long n);
|
2016-07-29 16:43:46 +08:00
|
|
|
|
|
2017-08-13 22:41:35 +08:00
|
|
|
|
/****************************************************************************/
|
|
|
|
|
|
2017-07-03 14:40:06 +08:00
|
|
|
|
typedef struct ACL_ATOMIC_CLOCK ACL_ATOMIC_CLOCK;
|
|
|
|
|
|
|
|
|
|
ACL_API ACL_ATOMIC_CLOCK *acl_atomic_clock_alloc(void);
|
|
|
|
|
ACL_API void acl_atomic_clock_free(ACL_ATOMIC_CLOCK *clk);
|
|
|
|
|
ACL_API long long acl_atomic_clock_count_add(ACL_ATOMIC_CLOCK *clk, int n);
|
|
|
|
|
ACL_API long long acl_atomic_clock_users_add(ACL_ATOMIC_CLOCK *clk, int n);
|
|
|
|
|
ACL_API void acl_atomic_clock_users_count_inc(ACL_ATOMIC_CLOCK *clk);
|
|
|
|
|
ACL_API long long acl_atomic_clock_count(ACL_ATOMIC_CLOCK *clk);
|
|
|
|
|
ACL_API long long acl_atomic_clock_atime(ACL_ATOMIC_CLOCK *clk);
|
|
|
|
|
ACL_API long long acl_atomic_clock_users(ACL_ATOMIC_CLOCK *clk);
|
|
|
|
|
|
2016-07-29 16:43:46 +08:00
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif
|