gopher-lua-libs
gopher-lua-libs copied to clipboard
Update plugin to work more like goroutines
Add a few more features to plugin to make it work more like go routines:
- Ensure the go p.start is really started (with
sync.Condandstarted) - so we know that the struct is consistently started when calling methods on it - Add the ability to pass simple args - those that don't rely on metatables such as string, number, channel and simple tables
- Add a
doneChwhich can be waited on by other plugin instances since a channel may be passed - Add convenience
waitthat waits for doneCh and returns error - Wrote a few unit test cases to show how to fire up plugins like goroutines, and communicate with channels.
- Solved the dependency loop by moving libs.Preload down to plugins and calling it from libs.Preload - so there's only one source of truth and each plugin has all the things loaded.
- Allow passing functions too as long as they aren't closures… allowing a plugin body like
pcall(unpack(arg))