lib-zo,C语言另一个协程库,函数列表
支持开启/禁用指定fd是否开启协程切换
void zcoroutine_enable_fd(int fd);
void zcoroutine_disable_fd(int fd);
函数列表
#pragma once
#ifndef ___ZC_LIB_INCLUDE_COROUTINE___
#define ___ZC_LIB_INCLUDE_COROUTINE___
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <sys/types.h>
#pragma pack(push, 4)
#ifdef __cplusplus
extern "C" {
#endif
typedef struct zcoroutine_base_t zcoroutine_base_t;
typedef struct zcoroutine_t zcoroutine_t;
typedef struct zcoroutine_mutex_t zcoroutine_mutex_t;
typedef struct zcoroutine_cond_t zcoroutine_cond_t;
typedef int zbool_t;
extern int zvar_coroutine_max_fd;
zcoroutine_base_t *zcoroutine_base_init();
zcoroutine_base_t *zcoroutine_base_get_current();
void zcoroutine_base_set_loop_fn(void (*loop_fn)(zcoroutine_base_t *cb));
void zcoroutine_base_run();
void zcoroutine_base_stop_notify(zcoroutine_base_t *cobs);
void zcoroutine_base_fini();
void zcoroutine_go(void *(*start_job)(void *ctx), void *ctx, int stack_kilobyte);
void zcoroutine_advanced_go(zcoroutine_base_t *cobs, void *(*start_job)(void *ctx), void *ctx, int stack_kilobyte);
zcoroutine_t * zcoroutine_self();
void zcoroutine_yield();
void zcoroutine_exit();
long zcoroutine_getid();
void zcoroutine_sleep_millisecond(int milliseconds);
void *zcoroutine_get_context();
void zcoroutine_set_context(const void *ctx);
void zcoroutine_enable_fd(int fd);
void zcoroutine_disable_fd(int fd);
zcoroutine_mutex_t * zcoroutine_mutex_create();
void zcoroutine_mutex_free(zcoroutine_mutex_t *);
void zcoroutine_mutex_lock(zcoroutine_mutex_t *);
void zcoroutine_mutex_unlock(zcoroutine_mutex_t *);
zcoroutine_cond_t * zcoroutine_cond_create();
void zcoroutine_cond_free(zcoroutine_cond_t *);
void zcoroutine_cond_wait(zcoroutine_cond_t *, zcoroutine_mutex_t *);
void zcoroutine_cond_signal(zcoroutine_cond_t *);
void zcoroutine_cond_broadcast(zcoroutine_cond_t *);
extern zbool_t zvar_coroutine_disable_udp;
extern zbool_t zvar_coroutine_disable_udp_53;
extern int zvar_coroutine_block_pthread_count_limit;
extern zbool_t zvar_coroutine_fileio_use_block_pthread;
void *zcoroutine_block_do(void *(*block_func)(void *ctx), void *ctx);
int zcoroutine_block_pwrite(int fd, const void *data, int len, long offset);
int zcoroutine_block_write(int fd, const void *data, int len);
long zcoroutine_block_lseek(int fd, long offset, int whence);
int zcoroutine_block_open(const char *pathname, int flags, mode_t mode);
int zcoroutine_block_close(int fd);
int zcoroutine_block_rename(const char *oldpath, const char *newpath);
int zcoroutine_block_unlink(const char *pathname);
#ifdef __cplusplus
}
#endif
#pragma pack(pop)
#endif