Multi-Thread Application problem

Steven Schveighoffer schveiguy at yahoo.com
Mon Feb 4 11:54:50 PST 2008


"Benjamin Schulte" wrote
> Hello,
>
> I'm having a problem with a problem in a multi threaded application since 
> several days.
>
> The problem itself is easy to describe. Let's say theres are two threads. 
> Thread A and Thread B.
> Thread A has to do most of the things for the application - drawing, 
> movement, etc. (It's a game)
> Thread B has to do all the loading stuff. Well since OpenGL doesn't 
> support handling drawing methods from Thread B there is a class that does 
> simply:
> Thread B requests to call something and waits for Thread A to handle it - 
> then it continues.
>
> But sometimes - without any real sense where it happens Thread A stops - 
> and Thread B - well, Thread B waits for Thread A at the told position.
>
>
> However, I now wondered if it's possible that a Thread goes into the 
> "critical mode" as soon a 'delete' is being called.
>
> like:
>
> delete abc;
> -->
> ~this( )
> {
> // Within this there is no thread switching??
> }
> <--
> // Now we can switch again
>
>
> Hope you can understand what I mean >.> *not the best english*

This seems to imply that you are doing a wait operation in your destructor? 
This is a bad idea.  Destructors are only for cleaning up system resources. 
Perhaps you can post your destructor code that you suspect is hanging here 
and we can have a look.

BTW, being in the destructor in itself will not force thread switching to 
stop, but if the destructor is being called by the garbage collector, all 
threads are halted while the garbage collector runs.

-Steve 





More information about the Digitalmars-d mailing list