Return multiple values from C++ Plugin, without the gSite.SetVariable


From what I understand, the only way to return multiple values from a c++ plugin function, is to use the gSite.SetVariable. Is this correct?

I am using version 6.27.1 64bit.


Is there a problem with multi-threading? ie if many AB threads are calling the DLL plugin, and each instance of the plugin sets an extra variable (called XYZ) through gSite.SetVariable. Is it certain that the correct Amibroker thread will read the correct instance of XYZ?

I am reading this article:

Will the above settings ensure the behaviour I want?

I am using DEV-C++ ver 5.11. I am trying to see how these settings correspond in Dev-C++.

You can just assume that I have thought of everything.

And no, there are no problems with multi-threading.
First each thread has completely independent set of variables and in fact separate thread-local memory.
So one thread can't read other thread variables (with the exception to STATIC variables that are shared).
Secondly your plugin is NEVER called from multiple threads at the same (i.e. concurrently). Users have no knowledge how to write re-entrant programs so plugin interface does not expect that and protects plugins from re-entrancy. Calls to 3rd party plugins are serialized and protected using internal critical section. So even if multiple threads are calling one function first one would wait for another to exit from your function.

The article you linked is about something else (using correct runtime). Runtime should just be correct.
Single-treaded C runtime is obsolete for at least 10 years now, incompatible with recent OSes and no-one should be using it anyway.

1 Like

Thank you very much @Tomasz, I am relieved now.

So this means that too many calls to plugins could diminish the benefit of multi-threading, right?