luvit / luv

Bare libuv bindings for lua
Apache License 2.0
831 stars 187 forks source link

Fix async #729

Closed javalikescript closed 1 week ago

javalikescript commented 2 weeks ago

Adds a reference count to async enabling to pass it properly as thread/async argument. Protects async arg using a mutex and defer clear to GC. Copy async arguments rather than using Lua ref.

Fix #505 Fix passing an async as async send argument then use it outside the callback function Fix suspect pop, here Fix thread join after exited

This PR attempts to keep the async/thread behavior, except for setting the userdata metadata in the async callback and passing empty userdata as light userdata. It may not be the best solution as it results in rather conplex and messy code.

javalikescript commented 1 week ago

Using a reference count is not enough, the async handle from another thread should have a specific behavior such as dedicated GC and close methods. I put this fix on hold looking for a simpler solution.