1

For a school project, I'm currently working with an external C++ library that I compile next to my own code. It works quite well, like this:

API_InitialiseProgram();
API_ComputeMyStuff(input_data);
Result output_data = API_GetResults();

Since I need to make use of the API for lots of different input data, I call upon these methods a lot. I figured I would make this code parallel. My first try of just running this code a few times in different threads of course didn't work, because the library uses globals.

Now I was wondering, it would stand to reason that I can make 'instances' of this library. So I can then concurrently run my code with different input in each instance. Is this hunch right? Or am I pursuing a dead end?

  • maybe something about static/dynamic linking? Though I'm not sure if it will matter with threads. – zoska May 13 '14 at 13:59
  • See http://stackoverflow.com/questions/1745975/load-multiple-copies-of-a-shared-library and http://stackoverflow.com/questions/3433522/loading-two-instances-of-a-shared-library – hyde May 13 '14 at 14:02
  • Why don't you try it and see? Let us know how it goes, and we'll help if you run into problems. – Software Engineer May 13 '14 at 14:07

0 Answers0