nelsonxb / coio Goto Github PK
View Code? Open in Web Editor NEWAn asynchronous IO library for Lua, based on coroutines.
License: MIT License
An asynchronous IO library for Lua, based on coroutines.
License: MIT License
In Lua, any function on the coroutine's stack can yield. It is possible to write a function that yields without the caller knowing it does this. In some ways, this is excellent. It means we are able to write a library that does async IO, and use other existing libraries that think they are using another blocking IO library.
However, one could imagine a case where one thread yields unexpectedly, while some shared variable is in an inconsistent state. We've suddenly run ourselves into a thread-safety situation, which async programmers may not be aware could happen (I've read a lot of people go on about how async programming avoids the problems with thread safety). You could very well argue that it's just straight careless to code in such a way as to allow this to happen, but you could also argue that it's not our place to assume our users are careful.
This idea hadn't occurred to me until I started this project, and I've been working with async happenings in JavaScript for quite some time. But, in JS, all async stuff is explicit. You always know when something is going to cause your algorithm to pause, because the language offers no ability to do otherwise. It is entirely possible that this explicitness will make someone realise at some point that they have to be careful.
So, here's the dilemma: should this API be such that we try to be explicit (like JavaScript's async/await), or do we keep with the benefits of allowing it to be implicit and just deal with the consequences carefully? Or is there a way to get the best of both worlds?
P.S.: If you happen to stumble upon this project before I answer this question myself, please be civil. It's so easy to get polarised when a yes/no question is asked, but refusing to see the situation from the other side never helps.
I was being lazy when I implemented this. It's a reasonably simple fix; when run is called, add the calling thread to our registry table so that the re-error code find it.
So now I have this building on both Linux and Mac (thanks to LuaRocks' built-in build system), but I have neither the system nor the expertise to ensure it works on Windows.
I'm welcoming input on this, and if any modifications to the rockspec are required then PR's are also welcome.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.