[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Loading a Lua module in two different states which run in two different threads with a mutex in place
- From: Andrew Gierth <andrew@...>
- Date: Sun, 16 Jun 2019 14:44:23 +0100
>>>>> "Abhijit" == Abhijit Nandy <abhijit.nandy@gmail.com> writes:
Abhijit> Hi,
Abhijit> I have a Lua module(DLL) which I want to use in two different
Abhijit> states which run in two different threads. There is a mutex to
Abhijit> prevent access to the module by both threads simultaneously.
Abhijit> If I load the module in the first state, then can I load it in
Abhijit> the second thread and use it(given that there is a mutex
Abhijit> preventing use from both threads and therefore states,
Abhijit> simultaneously). Could there be any issues if a module is
Abhijit> loaded in two different states in the same application?
This should work in principle (assuming the module itself doesn't do
anything wrong).
Each lua state maintains its own independent table of loaded modules, so
dlopen/LoadLibrary will be called twice; for both functions, this is
specifically allowed, and a reference count of the number of opens is
kept by the system so that the module isn't unmapped until it has been
closed as many times as it was loaded.
--
Andrew.