Writing game engine in C++, considering switching to D

John Colvin via Digitalmars-d digitalmars-d at puremagic.com
Fri Feb 20 07:26:01 PST 2015


On Friday, 20 February 2015 at 13:44:04 UTC, ponce wrote:
> On Friday, 20 February 2015 at 13:04:51 UTC, John Colvin wrote:
>> On Friday, 20 February 2015 at 09:57:48 UTC, 
>> francesco.cattoglio wrote:
>>> (e.g: if the GC calls any OpenGL function, you get a "nice" 
>>> crash since OpenGL is not multithread-aware by default).
>>
>> Really? I don't see this in my projects. The GC stops the 
>> world, so there shouldn't be any races.
>
> Not a race.
> An OpenGL contect can only active in one thread at once. If the 
> GC calls a destructor from a thread which doesn't have that 
> context active, it will probably crash.

Hmm, yeah you're right. That would explain some of my weirder 
crashes!

However, if you make the context current in the GC thread that's 
cleaning up, then you should be fine. There's nothing wrong with 
having the same context current in multiple threads as long as 
you don't access it concurrently.


More information about the Digitalmars-d mailing list