acl/lib_acl/include/msg/acl_aqueue.h

99 lines
2.7 KiB
C
Raw Normal View History

2014-11-19 00:25:21 +08:00
#ifndef ACL_AQUEUE_INCLUDE_H
#define ACL_AQUEUE_INCLUDE_H
#ifdef __cplusplus
extern "C" {
#endif
2017-06-02 14:47:24 +08:00
#include "../stdlib/acl_define.h"
#include "../thread/acl_thread.h"
2014-11-19 00:25:21 +08:00
#define ACL_AQUEUE_ERR_UNKNOWN -1
#define ACL_AQUEUE_OK 0
#define ACL_AQUEUE_ERR_LOCK 1
#define ACL_AQUEUE_ERR_UNLOCK 2
#define ACL_AQUEUE_ERR_TIMEOUT 3
#define ACL_AQUEUE_ERR_COND_WAIT 4
#define ACL_AQUEUE_ERR_COND_SIGNALE 5
typedef struct ACL_AQUEUE_ITEM ACL_AQUEUE_ITEM;
typedef struct ACL_AQUEUE ACL_AQUEUE;
typedef void (*ACL_AQUEUE_FREE_FN)(void *);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return ACL_AQUEUE <EFBFBD>ָ<EFBFBD><EFBFBD>
*/
ACL_API ACL_AQUEUE *acl_aqueue_new(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><EFBFBD><EFBFBD>иü<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> acl_aqueue_free
* @param queue ACL_AQUEUE <EFBFBD>ָ<EFBFBD><EFBFBD>
* @param flag <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
ACL_API void acl_aqueue_check_owner(ACL_AQUEUE *queue, char flag);
/**
* <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> acl_aqueue_free()
* @param queue ACL_AQUEUE <EFBFBD>ָ<EFBFBD><EFBFBD>
* @param owner <EFBFBD><EFBFBD><EFBFBD>̺߳ű<EFBFBD>ʶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD>ID<EFBFBD><EFBFBD>
*/
ACL_API void acl_aqueue_set_owner(ACL_AQUEUE *queue, unsigned int owner);
/**
* <EFBFBD>ͷŶ<EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param queue ACL_AQUEUE <EFBFBD>ָ<EFBFBD><EFBFBD>
* @param free_fn <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><EFBFBD>ͷ<EFBFBD>
*/
ACL_API void acl_aqueue_free(ACL_AQUEUE *queue, ACL_AQUEUE_FREE_FN free_fn);
/**
* <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 queue ACL_AQUEUE <EFBFBD>ָ<EFBFBD><EFBFBD>
* @return <EFBFBD>û<EFBFBD>ͨ<EFBFBD><EFBFBD> acl_aqueue_push <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
*/
ACL_API void *acl_aqueue_pop(ACL_AQUEUE *queue);
/**
* <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 queue ACL_AQUEUE <EFBFBD>ָ<EFBFBD><EFBFBD>
* @param tmo_sec <EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡԪ<EFBFBD>صij<EFBFBD>ʱʱ<EFBFBD><EFBFBD>, <EFBFBD><EFBFBD>λΪ<EFBFBD><EFBFBD>
* @param tmo_usec <EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡԪ<EFBFBD>صij<EFBFBD>ʱʱ<EFBFBD><EFBFBD>, <EFBFBD><EFBFBD>λΪ΢<EFBFBD><EFBFBD>
* @return <EFBFBD>û<EFBFBD>ͨ<EFBFBD><EFBFBD> acl_aqueue_push <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
*/
ACL_API void *acl_aqueue_pop_timedwait(ACL_AQUEUE *queue, int tmo_sec, int tmo_usec);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD>
* @param queue ACL_AQUEUE <EFBFBD>ָ<EFBFBD><EFBFBD>
* @param data <EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
* @return {int} <EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>, 0: ok; < 0: error
*/
ACL_API int acl_aqueue_push(ACL_AQUEUE *queue, void *data);
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>ζ<EFBFBD><EFBFBD>в<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, define as: ACL_AQUEUE_XXX
* @param queue ACL_AQUEUE <EFBFBD>ָ<EFBFBD><EFBFBD>
* @return <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
ACL_API int acl_aqueue_last_error(const ACL_AQUEUE *queue);
/**
* <EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>˳<EFBFBD>״̬
* @param queue ACL_AQUEUE <EFBFBD>ָ<EFBFBD><EFBFBD>
*/
ACL_API void acl_aqueue_set_quit(ACL_AQUEUE *queue);
/**
* <EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD>صĸ<EFBFBD><EFBFBD><EFBFBD>
* @param queue {ACL_AQUEUE*}
* @return {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD>ظ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>< 0 <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
ACL_API int acl_aqueue_qlen(ACL_AQUEUE* queue);
2014-11-19 00:25:21 +08:00
#ifdef __cplusplus
}
#endif
#endif