Threading

Steven Schveighoffer schveiguy at yahoo.com
Mon May 11 10:56:03 PDT 2009


On Mon, 11 May 2009 13:46:39 -0400, Brok3n Halo <x2ndshadow at hotmail.com>  
wrote:

> ah-ha! I was just writing to let you know that's how my project started  
> out and I
> went into this issue, when I decided to try it again and got an error  
> message I
> know how to solve.  Probably got it before too, but working off an  
> all-nighter and
> my caffeine hasn't fully kicked in yet. Turns out it's expecting an int
> testfunc(), the reason it wasn't working before was I was trying to use  
> a uint
> testfunc()
>
> Thanks for the heads up on the I/O issue with threading, the writefln  
> wasn't
> producing any output once I got it going and thanks to that I know what  
> the issue
> with that was right away, luckily my actual project doesn't require I/O  
> on a
> thread. (I'm writing a multi-threaded raytracer for a class)
>
> Which brings me to my next 2 questions, are dynamic arrays thread safe  
> in D? I
> imagine they should be as long as I don't have two threads writing to  
> the same
> index at once and the array size doesn't change.

They are no more thread safe than any other construct.  There is no  
special care taken to ensure writes or reads are thread safe, it is up to  
you to ensure that.

>  Also is there a thread safe
> linked list somewhere?

As far as I know, there are no builtin linked lists in D's standard  
library.

Tango, an alternate standard lib for D1, has linked lists, and  
dcollections, a collection package I wrote for both D1 phobos and Tango,  
has linked lists, neither of which has thread safety built in.

-Steve


More information about the Digitalmars-d-learn mailing list