Implementing a wait function #71
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hello! In my current project I implemented a very crude wait() method, where I literally just sleep the current thread for a desired length of time. This isn't very scalable, because if I have multiple lua scripts running, this becomes blocking and sleeps all scripts.
In my current project I run each script via a thread pool, but this doesn't seem like a good long-term solution. Since there can be hundreds of scripts in the project at any given time, I would rather not put them all on their own java thread.
I was wondering if there was a nicer way to implement wait(), such that it blocks only the current closure, but not additional scripts running in the application, or the current thread.
Still seeking a nice way to solve this issue! If anyone has any information I would love to hear your ideas!
Maybe a coroutine plus a Java timeout that will wake the coroutine up? (Dunno, not an expert.)
If I recall correctly, a coroutine in this library creates a LuaThread class, which creates a native java-Thread. I may be mistaken. I'll look a little more into this.
Maybe it would be better to implements Event-Handling like in JavaScript.
Implemented