Destruction in D
bitwise via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Apr 30 16:27:48 PDT 2015
On Thu, 30 Apr 2015 16:17:10 -0400, Adam D. Ruppe
<destructionator at gmail.com> wrote:
> On Thursday, 30 April 2015 at 20:07:11 UTC, bitwise wrote:
>> destructors are called on a separate thread, in parallel to the main
>> thread. Is this correct?
>
> Not necessarily. the way the GC works in D today is whenever any thread
> allocates, it runs the GC functions which might do a collection. This is
> where the destructors run, too.
>
> So a destructor may be run by whatever random thread happened to run out
> of memory and triggered the collection cycle.
>
>> What about structs? Are the destructors called when they go out of
>> scope in a C++ RAII fashion, or do they happen on a separate thread too?
>
> structs work basically the same as C++, yes.
>
>
> I don't know about your third thing...
Well, the third thing was just my reasoning for asking in the first place.
I need to be able to acquire/release shared resources reliably, like an
OpenGL texture, for example.
Come to think of of though, I haven't thought this issue through with
regard to multi-threaded rendering, so I guess I'll have to think of
something more clever than a ref-counted texture..
Thanks
Bitwise
More information about the Digitalmars-d-learn
mailing list