Comments (3)
Hm, maaaaybe, but using luster for anything serious is probably a ways off. I dunno, I'd have to think about exactly how to do it.
I think after luster is more usable and has a working userdata story, you could kind of do this without specific support in luster by taking advantage of the stackless nature. You'd need to have callbacks call something that sets up some state in a userdata, then the Sequence would pause, and on every sequence step you'd have to check for that waiting state to be set. Once it is set, you could wait on the condition to be fulfilled before resuming stepping the sequence?
This works because there's a whole lot of overlap between Sequences and Futures, so they give you some of the same abilities, they just have to be different due to lifetimes and threading the garbage collector context.
Is that the sort of thing you were thinking? I know that definitely isn't automatic, but you could maybe build something automatic off of that.
from piccolo.
Hmm so I'm not sure what Sequence
s exactly describe in luster (I haven't actually tried to read the implementation yet, still being in the exploratory phase). If I understand correctly, the process would be similar to:
- Compile the Lua code
- Start a Lua VM with the compiled Lua code
- When wanting to call a Lua function asynchronously:
- βCallβ the function on the Lua VM, this gives back a
Sequence
to be executed - Step-forward the
Sequence
, this processes the Lua code until the first builtin call - Try to asynchronously perform the builtin call, if it isn't ready, keep the paused
Sequence
and propagate not-readiness upwards to the (rust) caller - When it is ready, step-forward the
Sequence
again with the result of the builtin call, and go back to above point
- βCallβ the function on the Lua VM, this gives back a
If that is indeed approximately what you mean, then I think it'd be possible to wrap a library over this model so that it could be transparently be used as async, and thus that this issue will solve itself then!
Thank you for your answer, and sorry if I'm misunderstanding something for lack of knowledge of luster's internals. As for luster not being ready, don't worry, my project is very far from being ready too! hopefully we'll manage to get to something usable approximately simultaneously :)
from piccolo.
This is an extremely old issue, but I never responded to the question because this was about when I stopped working on the project for four years. I'm going through old PRs / issues right now.
When wanting to call a Lua function asynchronously:
- βCallβ the function on the Lua VM, this gives back a Sequence to be executed
- Step-forward the Sequence, this processes the Lua code until the first builtin call
- Try to asynchronously perform the builtin call, if it isn't ready, keep the paused Sequence and propagate not-readiness upwards to the (rust) caller
- When it is ready, step-forward the Sequence again with the result of the builtin call, and go back to above point
This is actually exactly how you would do it. Nowadays, you would specifically use Fuel::interrupt
to cause the Executor::step
driving Lua code to immediately return to Rust, (after registering some waker somewhere, or in some other way propagating unreadiness). I should make an example of this and put it somewhere...
from piccolo.
Related Issues (20)
- Luster Naming HOT 13
- Is TSETV a LuaJIT opcode or Lua opcode?
- Passing Lua bytecode to the compiler and getting an AST-Like return value HOT 5
- Implement `__newindex` Metamethod HOT 3
- Evaluate Profile-Guided Optimization (PGO)
- [BUG] Examples do not compile HOT 3
- Question: Serialization of entire Lua state HOT 2
- Suggestion: Nested FromLuaMulti HOT 5
- question HOT 2
- (Question) There's a CLI tool? HOT 1
- Unexpected panic: `assertion failed: self.stack.is_empty()` HOT 1
- Unexpected panic: `thread finalization was missed` HOT 9
- TailCail OpCode bug HOT 3
- Mapping a Lua function over a Rust Iterator HOT 3
- Small detail about JS Functions in your post. HOT 1
- question: are async calls into the vm Send? HOT 4
- Tables need to support "dead keys"
- Multiline strings aren't removing the initial newline HOT 1
- Unexpected values when calling function
- RawTable fmt::Debug implementation can overflow stack
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 piccolo.