Threading Questions

bitwise via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Oct 3 21:24:52 PDT 2015


On Tuesday, 29 September 2015 at 19:10:58 UTC, Steven 
Schveighoffer wrote:
>
> An object that implements the Monitor interface may not 
> actually be a mutex. For example, a pthread_cond_t requires a 
> pthread_mutex_t to operate properly.

Right! I feel like I should have caught the fact that 
ConditionVariable still has to use pthread_cond_t under the hood, 
and adopts all of it's behaviour and requirements as a result.

> 4. Technically, you shouldn't access member variables that are 
> GC allocated from a dtor. I know it's a struct, but structs can 
> be GC allocated as well.

Right.... forgot about that.

GC's are really beginning to get on my nerves.. IMO, RAII for GC 
is a horrible tradeoff.

I'm still not sure I would like Rust, but their memory model is 
making it a very enticing proposition. I'm almost at the point 
where I just don't care how much convenience, or familiarity D 
can offer in other areas.. Its starting to seem like none of it 
is worth it with a GC-based memory model standing in the way. 
Maybe this is an exageration...D has a lot of great features..but 
it's the net benefit that will ultimately determine whether or 
not people use D.

I use C#(garbage collected) for making apps/games, and while, 
_in_theory_, the GC is supposed to protect you from leaks, memory 
is not the only thing that can leak. Threads need to be stopped, 
graphics resources need to be released, etc.. So when I can't 
rely on RAII to free these things, I need to free them 
explicitly, which basically puts me right back where I started.

Anyways, I realize this will probably be buried 3 pages deep in 
D-Learn by Monday, but at least I feel better :)

     Bit



More information about the Digitalmars-d-learn mailing list