Honestly, I don't need the Lua lock and unlock methods. The Lua create childthread was all that I needed.
The old system I tried to implement mostly eliminated data races by breaking up critical functions and limiting reading and writing access.
The data path followed this with a job system.
UI -> Threaded AI - > Sync -> physics -> sync -> Entity State Update -> sync -> draw submit.
When the AI is running, Entity States are read only. Each AI is allowed to send messages to it's own entities, but not each other. This data is not applied until specific points in the pipeline.
For instance, once the AI does its updates, and the reading phase is done. We deactivate reading, switch to writing, and go ahead and allow the movement system to update it's velocities so it can follow any paths created by the AI.
The physics is ran after the syncing point. The physics system will generate a list of messages. The system will wait untill all physics jobs are done, giving the engine the go ahead to push onto the stateful updates. The messages will be pushed to Lua all at once.
Lua will then update the entity states (Health, animation, looking directions, etc).
The biggest problem would be adding data to the end of a list asynchronously. Theoretically, it might not be a problem. I think Lua uses a form of a linked list or something for arrays.