iqiyi/libfiber
FreeThe high performance c/c++ coroutine/fiber library for Linux/FreeBSD/MacOS/Windows, supporting select/poll/epoll/kqueue/iouring/iocp/windows GUI.
About iqiyi/libfiber
libfiber is a high-performance coroutine library for C/C++ developed by iQiyi. It enables writing network application services with high concurrency and performance more easily than traditional asynchronous event-driven models. The library supports multiple platforms including Linux, FreeBSD, macOS, and Windows, and integrates various I/O event mechanisms such as select, poll, epoll, kqueue, io_uring, and IOCP. Notably, it also supports Windows GUI message handling, allowing coroutine-based network modules in MFC, WTL, or other GUI frameworks. The library includes a rich set of APIs: base fiber management, I/O operations, networking (including socket and DNS), channels for inter-fiber communication, and synchronization primitives (mutex, event, wait_group). It offers both C and C++ (including C++11/14) APIs, API hooking for transparent coroutine support of blocking system calls, and comprehensive sample code for server/client, domain resolution, shared stack, inter-fiber/thread sync, HTTP server with routing, and Windows GUI.
Key Features
Pros & Cons
- Supports a wide range of OS platforms and I/O event mechanisms
- Enables writing concurrent network code in a synchronous style, reducing complexity
- Includes Windows GUI message integration, unique among coroutine libraries
- Provides both C and modern C++ APIs (C++11/14)
- API hooking allows seamless integration with existing blocking system calls
- Well-documented with many sample programs covering common patterns
- Relative to some alternatives (e.g., libuv, Boost.Asio), community adoption may be narrower
- API hooking may introduce overhead or compatibility issues in edge cases
- Documentation is primarily in the README and sample code; no separate extensive manual