# libfiber | iQIYI | Knowledge Base | Instagit

The high performance c/c++ coroutine/fiber library for Linux/FreeBSD/MacOS/Windows, supporting select/poll/epoll/kqueue/iouring/iocp/windows GUI.

GitHub Stars: 799

Repository: https://github.com/iqiyi/libfiber

---

## Articles

### [How to Use the C++ go_fiber API with Lambda Expressions in libfiber](/iqiyi/libfiber/how-to-use-cpp-go-fiber-api-with-lambda-expressions)

Learn to use the C++ go_fiber API with lambda expressions in libfiber. Launch fibers using intuitive lambda syntax via operator overloading on temporary go_fiber objects. Get started now.

- Tags: how-to-guide
- Published: 2026-03-04

### [How to Migrate libco or libmill Code to libfiber: A Complete Porting Guide](/iqiyi/libfiber/how-to-migrate-existing-libco-or-libmill-code-to-libfiber)

Effortlessly migrate your libco or libmill code to libfiber. Discover the simple steps to replace functions and run your scheduler for a seamless transition. Follow our complete porting guide.

- Tags: migration-guide
- Published: 2026-03-04

### [Thread-Safety Considerations When Mixing Libfiber Fibers with pthreads](/iqiyi/libfiber/thread-safety-considerations-when-mixing-fibers-with-pthreads)

Learn thread-safety considerations for mixing libfiber with pthreads. Discover how to avoid race conditions with independent schedulers and exclusive synchronization primitive use.

- Tags: best-practices
- Published: 2026-03-04

### [How to Use fiber_sem to Limit Concurrent Database Connections in libfiber](/iqiyi/libfiber/how-to-use-fiber-sem-to-limit-concurrent-database-connections)

Learn to limit concurrent database connections in libfiber using fiber_sem. Implement wait and post or use fiber_sem_guard for RAII-based connection management.

- Tags: how-to-guide
- Published: 2026-03-04

### [How to Use fiber_delay for Non-Blocking Timeouts in libfiber](/iqiyi/libfiber/how-to-use-fiber-delay-for-non-blocking-timeouts)

Master non-blocking timeouts with fiber_delay in libfiber. Suspend fibers effectively without blocking OS threads, enabling efficient cooperative multitasking.

- Tags: how-to-guide
- Published: 2026-03-04

### [How to Implement a Producer-Consumer Pattern Using Fiber Channels in libfiber](/iqiyi/libfiber/how-to-implement-producer-consumer-pattern-using-fiber-channels)

Implement the producer consumer pattern with libfiber channels. Learn to create bounded queues for lock-free coroutine communication. Suspend producers and consumers automatically.

- Tags: how-to-guide
- Published: 2026-03-04

### [How to Use the io_uring Event Mechanism on Modern Linux Kernels with libfiber](/iqiyi/libfiber/how-to-use-io-uring-event-mechanism-on-modern-linux-kernels)

Learn to use the io_uring event mechanism on Linux kernels with libfiber for high-performance asynchronous I/O. Enable io_uring at compile time and runtime for efficient operations.

- Tags: how-to-guide
- Published: 2026-03-04

### [How the Libfiber Fiber Scheduler Handles Multiple Threads: Per-Thread Architecture Explained](/iqiyi/libfiber/how-does-fiber-scheduler-handle-multiple-threads)

Discover how the libfiber fiber scheduler utilizes a per-thread architecture for efficient multi-threaded execution. Learn how isolated schedulers prevent fiber migration.

- Tags: internals
- Published: 2026-03-04

### [How to Use fiber_event for Efficient Fiber Synchronization in libfiber](/iqiyi/libfiber/how-to-use-fiber-event-for-efficient-fiber-synchronization)

Master fiber synchronization with libfiber's fiber_event. Learn to create, wait, and notify efficiently using acl_fiber_event functions for optimal performance in your applications.

- Tags: how-to-guide
- Published: 2026-03-04

### [Optimal Stack Size Configurations for libfiber Workloads: A Complete Guide](/iqiyi/libfiber/optimal-stack-size-configurations-for-different-workloads)

Discover optimal libfiber stack size configurations for your workload. Learn how to match private shared or pool allocation stacks to prevent memory issues and ensure peak performance.

- Tags: best-practices
- Published: 2026-03-04

### [How to Handle Graceful Fiber Cancellation and Shutdown in libfiber](/iqiyi/libfiber/how-to-handle-graceful-fiber-cancellation-and-shutdown)

Master graceful fiber cancellation and shutdown in libfiber. Learn to use FIBER_F_CANCELED, acl_fiber_canceled, acl_fiber_kill, and acl_fiber_signal for robust error handling and clean termination.

- Tags: how-to-guide
- Published: 2026-03-04

### [How to Debug Fiber Deadlocks and Memory Issues in libfiber](/iqiyi/libfiber/how-to-debug-fiber-deadlocks-and-memory-issues)

Debug libfiber deadlocks and memory issues effectively. Learn to use acl_fiber_ndead, acl_fiber_memstat, instrument fiber_swap and __lock, and enable FIBER_STACK_GUARD for robust debugging.

- Tags: how-to-guide
- Published: 2026-03-04

### [libfiber vs libco vs libmill vs Go: Performance Benchmark Comparison](/iqiyi/libfiber/performance-benchmark-comparison-libfiber-libco-libmill-golang)

Discover the libfiber performance benchmark against libco, libmill, and Go. See how libfiber achieves superior transactions per second while maintaining POSIX compatibility. Read the comparison now.

- Tags: performance
- Published: 2026-03-04

### [How Windows GUI Message Pump Integrates with Fiber Scheduling in libfiber](/iqiyi/libfiber/how-does-windows-gui-message-pump-integrate-with-fiber-scheduling)

Explore how libfiber integrates the Windows GUI message pump with fiber scheduling via a hidden window and WSAAsyncSelect. Learn how Windows messages become fiber readiness events.

- Tags: internals
- Published: 2026-03-04

### [How DNS Resolution Works in Coroutines Without Blocking the Scheduler](/iqiyi/libfiber/how-does-dns-resolution-work-in-coroutines-without-blocking-scheduler)

Learn how libfiber resolves DNS in coroutines without blocking your scheduler. Discover its non-blocking UDP sockets and explicit yielding for efficient hostname resolution.

- Tags: deep-dive
- Published: 2026-03-04

### [How wait_group Synchronizes Multiple Fibers and Threads in libfiber](/iqiyi/libfiber/how-does-wait-group-synchronize-multiple-fibers-and-threads)

Learn how libfiber's wait_group synchronizes fibers and threads using a 64-bit atomic state and lock-free mailbox for efficient completion signaling across heterogeneous contexts.

- Tags: deep-dive
- Published: 2026-03-04

### [How to Create and Use a Fiber Pool for High-Performance Task Execution in libfiber](/iqiyi/libfiber/how-to-create-and-use-fiber-pool-for-high-performance-task-execution)

Learn to create and use a fiber pool in libfiber for high-performance task execution. Discover lock-free queues, auto-scaling, and minimal overhead for efficient scheduling.

- Tags: how-to-guide
- Published: 2026-03-04

### [How the Fiber Channel API Enables Inter-Fiber Communication in libfiber](/iqiyi/libfiber/how-does-fiber-channel-api-enable-inter-fiber-communication)

Discover how the fiber channel API in libfiber facilitates inter-fiber communication through buffered or unbuffered channels and a cooperative scheduler for seamless data exchange.

- Tags: internals
- Published: 2026-03-04

### [How to Use fiber_mutex for Cross-Fiber and Cross-Thread Synchronization in libfiber](/iqiyi/libfiber/how-to-use-fiber-mutex-for-cross-fiber-cross-thread-synchronization)

Master fiber_mutex for seamless cross-fiber and cross-thread synchronization in libfiber. Learn to prevent data races and ensure thread safety with this powerful synchronization primitive.

- Tags: how-to-guide
- Published: 2026-03-04

### [How to Integrate libfiber with a MySQL Driver Without Modifying the Source Code](/iqiyi/libfiber/how-to-integrate-libfiber-with-mysql-driver-without-modifying-source)

Integrate libfiber with MySQL driver effortlessly. Run libmysqlclient code in coroutines without source code modification. Optimize your database interactions.

- Tags: how-to-guide
- Published: 2026-03-04

### [How the libfiber API Hook Mechanism Replaces Standard System Calls on Linux/BSD](/iqiyi/libfiber/how-does-api-hook-mechanism-replace-system-calls-on-linux-bsd)

Discover how libfiber's API hook mechanism replaces Linux/BSD system calls. It uses dynamic linker interposition to wrap libc functions with cooperative scheduling for efficient fiber management.

- Tags: how-to-guide
- Published: 2026-03-04

### [How to Configure Shared Stack Mode in libfiber to Reduce Memory Usage](/iqiyi/libfiber/how-to-configure-shared-stack-mode-to-reduce-memory-usage)

Reduce memory usage in libfiber by configuring shared stack mode. Learn to set the ACL_FIBER_ATTR_SHARE_STACK flag or use go_share(size) to reuse stack buffers efficiently.

- Tags: how-to-guide
- Published: 2026-03-04

### [FIBER_EVENT_KERNEL vs FIBER_EVENT_POLL vs FIBER_EVENT_SELECT in libfiber](/iqiyi/libfiber/differences-between-fiber-event-kernel-poll-select)

Understand differences between FIBER_EVENT_KERNEL, FIBER_EVENT_POLL, and FIBER_EVENT_SELECT in libfiber. Choose the best event multiplexer for your concurrency needs.

- Tags: deep-dive
- Published: 2026-03-04

### [How libfiber's Scheduler Works Internally: Cooperative Fiber Scheduling in C](/iqiyi/libfiber/how-does-libfibers-scheduler-work-internally)

Discover how libfiber's scheduler works internally. Learn about cooperative fiber scheduling in C through thread-local state machines, FIFO queues, and assembly context switches.

- Tags: internals
- Published: 2026-03-04

