C ++, multiple instances of dll, singleton

I have a dll in which singleton is defined.

I have an application that can load multiple instances of this dll.

The DLL needs a singleton instance for the DLL instance, otherwise it will crash.

I noticed that for multiple instances of a DLL, there is only one singleton instance. What for? How can I solve it (if possible, without reorganizing the singleton into something else?)

Thanks for any help.

+3
source share
3 answers

You mentioned that you have multiple instances within the application , which means that they all live within the same process.

, , , , DLL ..

+1

. DLL "" . , , ( DLL ).

"singleton", .

+1

dll, , "singleton" . , dll.

Then, of course, you should come up with some kind of communication scheme between your main process and your child processes, which will depend on how much you use the dll. Is this just a couple of calls with lots of data? Or are there many different calls that differ from run to run?

Generally, if you use a dll to create more than a few simple calls, it may be easier to reorganize your own code.

+1
source

Source: https://habr.com/ru/post/1784056/


All Articles