一个 `boost::fiber` 库的示例
原文英文,约600词,阅读约需2分钟。发表于: 。Fiber is just a thread implemented in user space. Fibers are easier to reason about and have perf advantage of much cheaper context switching. Fibers are very well suited for handling concurrent...
纤维是一种用户空间的线程,适合处理并发IO操作,具有较低的上下文切换成本。本文展示了一个简单程序,创建两个分离的纤维,分别调用print_a和print_b函数,直到共享变量i达到20。程序输出包含十个a、十个b和十个B,B的位置不确定。