Closed Parakleta closed 8 years ago
I think your proposal is reasonable, since Lua states are thread-safe data; however, you still can't safely use a Lua state in more than one thread since mutating a state from more than one thread at a time causes undefined behavior.
Not using it simultaneously is handled by the Sync
trait, which would not be applied. This just means that it needs to be wrapped in a Mutex. The problem is that without the Send
trait the Mutex will not apply the Sync
trait.
Since
State
properly manages the ownership of its contained pointer it should be madeSend
withunsafe impl Send for State {}
so that once wrapped in a Mutex the Lua State can be shared between threads.