Click here to Skip to main content
15,888,527 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionwarning LNK4222: exported symbol 'DllRegisterServer' should not be assigned an ordinal Pin
sashoalm12-Mar-10 2:51
sashoalm12-Mar-10 2:51 
AnswerRe: warning LNK4222: exported symbol 'DllRegisterServer' should not be assigned an ordinal Pin
Eugen Podsypalnikov12-Mar-10 3:02
Eugen Podsypalnikov12-Mar-10 3:02 
GeneralRe: warning LNK4222: exported symbol 'DllRegisterServer' should not be assigned an ordinal Pin
sashoalm12-Mar-10 3:09
sashoalm12-Mar-10 3:09 
QuestionSeven : What Happended To ShellExecute ? Pin
Nicolas MEURET12-Mar-10 2:11
Nicolas MEURET12-Mar-10 2:11 
QuestionRe: Seven : What Happended To ShellExecute ? Pin
sashoalm12-Mar-10 3:23
sashoalm12-Mar-10 3:23 
AnswerRe: Seven : What Happended To ShellExecute ? [modified] Pin
Nicolas MEURET12-Mar-10 4:38
Nicolas MEURET12-Mar-10 4:38 
GeneralRe: Seven : What Happended To ShellExecute ? Pin
sashoalm12-Mar-10 5:27
sashoalm12-Mar-10 5:27 
QuestionHaving different value for a global variable per thread. Pin
Code-o-mat12-Mar-10 1:20
Code-o-mat12-Mar-10 1:20 
Hello folks!

I was just wondering, and thought i ask you, maybe some of you have nice ideas. So here's the deal: there is a static function i have to implement, but its declaration/definition has to match a certian predefined "form", i can write the implementation as i see fit but i can't change the number and types of parameters passed. Let's call this function: TheStaticFunction(). This is actually a callback function that gets called regularry while a 3rd party system is doing its processing. Now, if i want to pass some parameters to this method, i have to use some global variable(s), set them before letting the 3rd party processing begin, eg:
int global_parameter_variable;

void TheStaticFunction()
{
  ... use value of global_parameter_variable as needed ...
}

...
void Do3rdPartProcessing()
{
  global_parameter_variable = 123;
  Perform3rdPArtyProcessing();
}
This aproach works ok as long as i don't want to use multiple threads to do the processing but with different parameters per thread, since there's only one global global_parameter_variable.
So my question is: what could be done to achieve this?
One solution that comes to my mind is having some global object that stores the parameter values associated with thread handles. So when a thread is trying to use the 3rd party method, it stores its own parameter value associated with its own handle in this global object and inside the static method this global object is used to query the parameter value for the current thread. So something like this:
CThreadedParameters globa_parameter_retriever;

void TheStaticFunction()
{
  ...
  int the_parameter = globa_parameter_retriever.GetParameterValueForThread(GetCurrentThreadHandle());
  ...
}

void Do3rdPartProcessing(int parameter)
{
  globa_parameter_retriever.SetParameterValueForThread(GetCurrentThreadHandle(), parameter);
  Perform3rdPArtyProcessing();
  globa_parameter_retriever.RemoveParameterValueFor(GetCurrentThreadHandle());
}
Of course access to the globa_parameter_retriever would be properly synchronized. This method would probably work but you would have to perform a lookup based on the current thread's handle every time TheStaticFunction is called, althorough this is most likely now that much of an overhaul. So does anyone have any other idea or knows any other, simpler method that exists and i just don't know about it? This all is for now only hypothetical so i can't give you any test results. Thanks for your oppinions.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <

AnswerRe: Having different value for a global variable per thread. Pin
sunlin712-Mar-10 1:37
sunlin712-Mar-10 1:37 
GeneralRe: Having different value for a global variable per thread. Pin
Code-o-mat12-Mar-10 1:44
Code-o-mat12-Mar-10 1:44 
AnswerRe: Having different value for a global variable per thread. Pin
Jonathan Davies12-Mar-10 1:38
Jonathan Davies12-Mar-10 1:38 
GeneralRe: Having different value for a global variable per thread. Pin
Code-o-mat12-Mar-10 1:44
Code-o-mat12-Mar-10 1:44 
AnswerRe: Having different value for a global variable per thread. Pin
Chris Losinger12-Mar-10 3:25
professionalChris Losinger12-Mar-10 3:25 
GeneralRe: Having different value for a global variable per thread. Pin
Code-o-mat12-Mar-10 3:30
Code-o-mat12-Mar-10 3:30 
AnswerRe: Having different value for a global variable per thread. Pin
Russell'12-Mar-10 8:48
Russell'12-Mar-10 8:48 
GeneralRe: Having different value for a global variable per thread. Pin
Code-o-mat12-Mar-10 10:12
Code-o-mat12-Mar-10 10:12 
QuestionHow to find source of buffer overflow Pin
WernerP11-Mar-10 23:44
WernerP11-Mar-10 23:44 
AnswerRe: How to find source of buffer overflow Pin
Eugen Podsypalnikov12-Mar-10 0:08
Eugen Podsypalnikov12-Mar-10 0:08 
AnswerRe: How to find source of buffer overflow Pin
Eugen Podsypalnikov12-Mar-10 0:24
Eugen Podsypalnikov12-Mar-10 0:24 
GeneralRe: How to find source of buffer overflow Pin
WernerP12-Mar-10 2:19
WernerP12-Mar-10 2:19 
GeneralRe: How to find source of buffer overflow Pin
Eugen Podsypalnikov12-Mar-10 2:44
Eugen Podsypalnikov12-Mar-10 2:44 
AnswerRe: How to find source of buffer overflow Pin
CPallini12-Mar-10 0:35
mveCPallini12-Mar-10 0:35 
AnswerRe: How to find source of buffer overflow Pin
Adam Roderick J12-Mar-10 0:53
Adam Roderick J12-Mar-10 0:53 
GeneralRe: How to find source of buffer overflow Pin
WernerP12-Mar-10 2:21
WernerP12-Mar-10 2:21 
Questiongiving url to .ini file Pin
jannathali11-Mar-10 23:25
jannathali11-Mar-10 23:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.