Le 2012-01-16 à 09:43:00, IOhannes m zmoelnig a écrit :
what is wrong with eliminating all directly accessible globals from the API (like "pd_objectmaker") and provide accessor functions to get (thread safe) access to them?
Or just structs. You'd have a t_pdglobal type containing all the global variables that should never be shared.
And a separate section of the same struct could also list the global variables that could be shared, but might be not (e.g. if there's any reason to support both a single symtable and multiple symtables).
afaik, the usual way to accomplish a concept of multiple instances is to aggragate all currently global variables into a "context" and extend the API so that each function has an additional parameter for this context.
I mean that this context could be accessed directly if there's no reason to use accessors. But if locking has to be done before and after accessing (some of) those members, then it's nice to have a shortcut.
this will obviously break API compatibility... a possible workaround would be to add a new function "t_pdcontext*make_current(t_pdcontext*)" that would change the running instance and all API calls would henceforth work on the current context. this would still need a global variable (the current context). the "make_current" call could update the legacy global variables to contain the "current" values. (this would only work as long as no code caches the values of these variables).
how many of these variables are there ? That could be a lot of variables to be swapped around.
e.g. c++11 (c++? ever tried to compile Pd with a c++ compiler?)
I did. I don't recall significant difficulties... it might have been just the need to explicitly cast float to int, and something else involving void pointers... the job of making it compile with C++ wasn't a portion worth mentioning of the project I was working on (less than 1 %).
It took less time than just getting rid of all of pd's unused variables just so that I could see my own mistakes easily.
______________________________________________________________________ | Mathieu BOUCHARD ----- téléphone : +1.514.383.3801 ----- Montréal, QC