tomaka / hlua

Rust library to interface with Lua
MIT License
510 stars 48 forks source link

Support for lua_sethook from hlua #194

Open beatgammit opened 6 years ago

beatgammit commented 6 years ago

I'd like to be able to set hooks to do stuff like rate limiting the execution of Lua code. Production use cases:

And then there's the typical debugging tasks, but this isn't as important for me.

I think I can get the last one by using debug.sethook within a Lua script, but I think the first two would require support from hlua itself.

Ideally, this would allow resuming a task that's been pre-empted (to solve the second use case).

Is this something you're interested in supporting? If so, do you anticipate any problems in implementation? I may be able to contribute something, but I'd like direction before getting started.

EDIT: It looks like I don't need support from hlua for the first use-case, and can get a pretty decent result by running all user code in a closure. I'm not sure about the second though.