Click here to Skip to main content
15,917,731 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: udp packet Pin
Mike Nordell4-Mar-03 0:26
Mike Nordell4-Mar-03 0:26 
Generalcombo box item selection Pin
Arungs3-Mar-03 19:30
Arungs3-Mar-03 19:30 
GeneralProblems with a check box Pin
MaTrIX2k23-Mar-03 19:08
MaTrIX2k23-Mar-03 19:08 
GeneralRe: Problems with a check box Pin
Alvaro Mendez4-Mar-03 11:14
Alvaro Mendez4-Mar-03 11:14 
GeneralRe: Problems with a check box Pin
MaTrIX2k24-Mar-03 14:41
MaTrIX2k24-Mar-03 14:41 
Generalhandel and window Pin
aguest3-Mar-03 12:29
aguest3-Mar-03 12:29 
GeneralRe: handel and window Pin
Dave Bryant3-Mar-03 12:39
Dave Bryant3-Mar-03 12:39 
GeneralHELP! Parent-Child Thread Data Problem Pin
Ecom Wang3-Mar-03 12:25
sussEcom Wang3-Mar-03 12:25 
Help please!!! We are running into the following problem:

How can we share global instance data among multiple parent-child thread branches under Win32?

Thread Local Storage can be used if you have two threads which each need
their own global instance of a class:

fooKey=TLSAlloc();
TLSSetValue(fooKey,new Foo()); //TLS for foo=new Foo();
foo=TLSGetValue(fooKey);
foo->bar(); //each thread gets its own foo instance

However, what if the two threads each spawn a new thread which needs
to address foo (and you can't pass foo in during the thread create because
the thread is created in a library call which we don't have access to):

Main Thread
/ \
thread A1 thread B1 foo=new Foo(); //our code
| |
thread A2 thread B2 //not our code
| |
thread A3 thread B3 foo->bar(); //our code

We want A3's foo instance to be the same as A1, and B3's instance
to be the same as B1, but for A1 and B1 to be different.
Here we can't use TLS because thread A3 would be different than A1
since their thread IDs are different.

We thought of making our own TLS which would use the parent thread
ID (I know it isn't a true parent-child relationship, but in this
case we are calling the spawning thread the parent) for the lookup
if there is no storage under the thread's own ID, but we haven't
found a Win32 API call that permits us to know the parent ID (and
again, if we were directly calling CreateThread, _beginthreadex
or other thread family functions,
we could pass the shared data wrapped in the thread parameter, but
unfortunately we aren't creating the thread ourselves so we can't pass data
in or even get the thread ID when it is created...in actuality, there
is even a 3rd thread in-between the other two but that isn't critical
to finding a solution here...)


Thanks for your help. If you have any suggestions, please send me a
email at ecomwang@yahoo.com.



GeneralRe: HELP! Parent-Child Thread Data Problem Pin
Scott H. Settlemier4-Mar-03 9:57
Scott H. Settlemier4-Mar-03 9:57 
General. Pin
aguest3-Mar-03 12:23
aguest3-Mar-03 12:23 
GeneralRe: . Pin
benjymous4-Mar-03 1:15
benjymous4-Mar-03 1:15 
Generalhandel of EditBox and window Pin
aguest4-Mar-03 10:31
aguest4-Mar-03 10:31 
GeneralPbm with Registry function Pin
RaajaOfSelf3-Mar-03 11:46
RaajaOfSelf3-Mar-03 11:46 
GeneralRe: Pbm with Registry function Pin
Brian Shifrin3-Mar-03 12:02
Brian Shifrin3-Mar-03 12:02 
GeneralRe: Pbm with Registry function Pin
RaajaOfSelf3-Mar-03 12:24
RaajaOfSelf3-Mar-03 12:24 
GeneralRe: Pbm with Registry function Pin
Dave Bryant3-Mar-03 12:50
Dave Bryant3-Mar-03 12:50 
GeneralRe: Pbm with Registry function Pin
ramki-kicha3-Mar-03 19:52
sussramki-kicha3-Mar-03 19:52 
GeneralRe: Pbm with Registry function Pin
Jon Hulatt4-Mar-03 3:04
Jon Hulatt4-Mar-03 3:04 
QuestionWindow with Close button but no titlebar Icon? Pin
Aidman3-Mar-03 11:11
Aidman3-Mar-03 11:11 
AnswerRe: Window with Close button but no titlebar Icon? Pin
Zdeslav Vojkovic3-Mar-03 22:36
Zdeslav Vojkovic3-Mar-03 22:36 
GeneralRe: Window with Close button but no titlebar Icon? Pin
Aidman4-Mar-03 5:32
Aidman4-Mar-03 5:32 
QuestionDisplaying a bitmap? Pin
Paddy3-Mar-03 10:30
Paddy3-Mar-03 10:30 
AnswerRe: Displaying a bitmap? Pin
Brian Shifrin3-Mar-03 12:07
Brian Shifrin3-Mar-03 12:07 
GeneralRe: Displaying a bitmap? Pin
Paddy3-Mar-03 13:18
Paddy3-Mar-03 13:18 
GeneralRe: Displaying a bitmap? Pin
MAAK3-Mar-03 22:22
MAAK3-Mar-03 22:22 

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.