#ifndef _epoll_fd_shm_h_ #define _epoll_fd_shm_h_ #ifndef HIDDENAPI #define HIDDENAPI __attribute__((visibility("hidden"))) #endif #ifdef __cplusplus extern "C" { #endif int unix_domain_server_fd(const char* path, int nonblock); int unix_domain_client_fd(const char* path, int nonblock); struct fd_msg{ void* data; union{ int len; int fd; }; }; typedef int(*cbGetData)(void* args, struct fd_msg* msg); typedef cbGetData cbHandleData; typedef int(*cbQuit)(void* args); // 效率很高,但是无法保证给所有的客户端发送同一个消息, 2w+/s int epoll_loop(int listenfd, cbGetData fget, cbHandleData fhandle, cbQuit fquit, void* args); int poll_loop(int listenfd, cbGetData fget, cbHandleData fhandle, cbQuit fquit, void* args); int select_loop(int listenfd, cbGetData fget, cbHandleData fhandle, cbQuit fquit, void* args); // 认为大部分时间都可写,保证给客户端发送同一个消息, block IO, only send, 1w+/s int simple_loop(int listenfd, cbGetData fget, cbQuit fquit, void* args); // 客户端没有并发需求,只需要在 loop 中不停 recvfd 即可 // 应该没什么用 HIDDENAPI void free_fd_msg(struct fd_msg* msg); #ifdef __cplusplus } #endif #endif