LWL/nlib/buffer/buffer.h

117 lines
2.6 KiB
C
Raw Normal View History

2024-07-10 06:01:39 +00:00
#ifndef _BUFFER_H_
#define _BUFFER_H_
#include <StdBool.h>
/***********************************<2A><EFBFBD><EABFAA>**********************************/
#define OPENLOCK 1
#define BUFFER_MALLOC malloc
/************************************<2A><><EFBFBD>Ͷ<EFBFBD><CDB6><EFBFBD>********************************/
/*buffer<65><72><EFBFBD><EFBFBD>*/
typedef void* BufferHandle;
/*<2A>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
typedef void(*BufferFuc)(BufferHandle);
/*<2A>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
typedef void(*BufferActFuc)();
/**************************************<2A><><EFBFBD><EFBFBD>**************************************/
/*<2A><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>NULLʧ<4C>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>buffer<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD>βΣ<EFBFBD>
* <EFBFBD><EFBFBD>
*/
extern BufferHandle FCreatBuffer(void);
/*<2A><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>0<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>buffer<EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD>βΣ<EFBFBD>
* buffer<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>buffer
* data<EFBFBD><EFBFBD>buffer<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>׵<EFBFBD>ַ
* unitSize<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* bufferMaxLen<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>
*/
extern int FInitBuffer(BufferHandle handleBuffer,void* data,unsigned int unitSize,unsigned int bufferMaxLen);
/*<2A><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>0<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><EFBFBD>ܳ<EFBFBD>ʱ<EFBFBD><EFBFBD>ȡ
* <EFBFBD>βΣ<EFBFBD>
* handleBuffer<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* timeout<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>
*/
extern int FInitBufferRecTime(BufferHandle handleBuffer,int timeout);
/*<2A><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>0<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD>buffer
* <EFBFBD>βΣ<EFBFBD>
* buffer<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>buffer
* data<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><EFBFBD>׵<EFBFBD>ַ
*/
extern int FPushBuffer(BufferHandle handleBuffer,void* data);
/*<2A><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>0<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>buffer
* <EFBFBD>βΣ<EFBFBD>
* buffer<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>buffer
* data<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>ָ<EFBFBD><EFBFBD>
*/
extern int FPopBuffer(BufferHandle handleBuffer,void* data);
/*<2A><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CPU<EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD>βΣ<EFBFBD>
* buffer<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>buffer
*/
extern void FBufferTask(BufferHandle handleBuffer);
/*<2A><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD>󶨻<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><EFBFBD>ܺ<EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD>βΣ<EFBFBD>
* handleBuffer<EFBFBD><EFBFBD><EFBFBD>󶨵Ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* func<EFBFBD><EFBFBD><EFBFBD>󶨵ĺ<EFBFBD><EFBFBD><EFBFBD>
*/
extern void FBufferBindMsgFuc(BufferHandle handleBuffer,BufferFuc func);
/*<2A><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><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>
* handleBuffer<EFBFBD><EFBFBD><EFBFBD>󶨵Ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* func<EFBFBD><EFBFBD><EFBFBD>󶨵ĺ<EFBFBD><EFBFBD><EFBFBD>
*/
extern void FBufferBindOverFuc(BufferHandle handleBuffer,BufferFuc func);
/***********************************<2A><>Ҫ<EFBFBD><D2AA>ֲ*********************************/
/*<2A><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD>󶨻<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD>βΣ<EFBFBD>
* handleBuffer<EFBFBD><EFBFBD><EFBFBD>󶨵Ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* func<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
extern void FBufferBindLockFunc(BufferHandle handleBuffer,BufferActFuc func);
/*<2A><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><EFBFBD>󶨻<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD>βΣ<EFBFBD>
* handleBuffer<EFBFBD><EFBFBD><EFBFBD>󶨵Ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* func<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*/
extern void FBufferBindUnLockFunc(BufferHandle handleBuffer,BufferActFuc func);
#endif