9 Star 34 Fork 10

linuxmail / lib-zo

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
contribute
Sync branch
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README
MIT

lib-zo

一个 C 协程库

本协程库是从 https://gitee.com/linuxmail/lib-zc 抽出来的, 可单独使用

帮助文档 https://gitee.com/linuxmail/lib-zc/blob/master/doc/coroutine.md

感谢

本协程库的实现参考了 libco, libgo, nodejs 的实现

介绍

支持文件IO类协程化(如mkdir, getdents等)

支持协程条件, 协程锁

慢操作协程化

支持sleep

可以禁用 UDP 协程切换

部分支持dns协议

支持静态编译

睡眠

支持sleep

不支持usleep和nanosleep

毫秒睡眠请用 void zcoroutine_sleep_millisecond(int milliseconds);

支持的文件io

可开启支持文件io在其他线程池工作

open, openat, close, read, readv, write, writev, lseek,

fdatasync, fsync, rename, truncate, ftruncate,

rmdir, mkdir, getdents,

stat, fstat, lstat, link, symlink, readlink, unlink,

chmod, fchmod, chown, fchown, lchown, utime, utimes,

支持慢(阻塞式)操作

慢操作可以在其他线程池工作

dns协议

本框架下, 大部分 glibc 版本的 DNS 解析会有 BUG, 但至少版本 2.12 没问题

如果有问题, 建议:

  • 如果需要查询常用域名的 IP 地址, 可以写到 hosts 文件
  • 可以考虑 "慢操作协程化"
  • 可以禁用 53 端口(既 DNS)的 UDP 协程切换

可以禁用 UDP 协程切换

可以禁用 UDP 协程切换, 可以禁用 53 端口(既 DNS)的 UDP 协程切换

源码目录

coroutine.c coroutine.h 是源码

*_test.c 是例子

编译

make

得到

libzc_coroutine.a

使用

gcc your_code.c ./libzc_coroutine.a

MIT License Copyright (c) 张岩. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE

About

C协程库, 单文件易于迁移. 支持文件IO类协程化(如mkdir, getdents等) 支持协程条件, 协程锁 慢操作协程支持 expand collapse
C and 2 more languages
MIT
Cancel

Releases

No release

Contributors

All

Activities

Load More
can not load any more
C
1
https://gitee.com/linuxmail/lib-zo.git
git@gitee.com:linuxmail/lib-zo.git
linuxmail
lib-zo
lib-zo
master

Search