Comments (3)
First, you would find the handle of the coroutine to which you want to yield to using co_active()
, and then would jump ("yield") to it from another coroutine using co_switch()
.
For more details, look up Symmetric Coroutines vs Asymmetric Coroutines, and how one can be emulated in terms of another. Here's one paper from Lua's developers.
from libco.
and also, once a co_thread are finished, what's I need to do to remove it from co_switch?
I need some demo for that. This is a wonderfull library that also works on bare-metal:)
Just need a bit improvement about the API to easier to use
from libco.
co_switch()
doesn't automatically switch to another thread, it only switches to the thread you name. If you want to stop switching to a particular thread, you just stop calling co_switch()
on it.
If you never want to switch to a particular thread again, you should stop calling co_switch()
on it, and probably also call co_delete()
on it to deallocate the memory used for the stack.
from libco.
Related Issues (18)
- On windows, calling to fflush(stdout); in co thread would cause crash. HOT 1
- What is the purpose of co_active_buffer? HOT 6
- User data/closure support HOT 7
- Add full copy of the exact version of ISC License to the repository?
- restore libco history HOT 2
- libco x86_64 currently doesn't build in ANSI C89 mode HOT 2
- Teach libco about valgrind HOT 3
- Idea: Use GCC inline asm instead of saving all the registers HOT 6
- How to finish a program? HOT 8
- How to running this on bare-metal system? such as MCU
- amd64.c co_derive assumes the input pointer is 16-aligned
- Support building with MSVC HOT 9
- Add an option to pass the stack in but not using malloc HOT 1
- Consider removing LIBCO_NO_SSE, or adding louder warnings
- RISC V HOT 2
- How to pass parameter to entry function? HOT 5
- How about convert the usage to markdown? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libco.