Re: Passing large or complex data structures to threads

2013-05-31 Thread Joseph Rushton Wakeling
On 05/27/2013 02:08 PM, Joseph Rushton Wakeling wrote: > On 05/26/2013 05:59 PM, Ali Çehreli wrote: >> On 05/26/2013 05:38 AM, Simen Kjaeraas wrote: >> >> >>> Tuple!(size_t, size_t)[][] data = createData(); >>> immutable dataImm = assumeUnique(data); >>> data = null; // Simply to ens

Re: Passing large or complex data structures to threads

2013-05-28 Thread Joseph Rushton Wakeling
On 05/28/2013 08:56 AM, Ali Çehreli wrote: > That is a difficult situation to manage though: What operations are valid > under > the 8 total mutable combinations of 3 members? The compiler must know what > operations to be applied on what type of data so that it can both check the > code > and co

Re: Passing large or complex data structures to threads

2013-05-28 Thread Ali Çehreli
On 05/27/2013 06:55 PM, Joseph Rushton Wakeling wrote: > On 05/27/2013 11:33 PM, Simen Kjaeraas wrote: >> Short answer: If you will have mixed arrays, no. There's no way to make >> that safe. If you don't have mixed arrays, there are ways. > > So you mean there's no way to have one member variab

Re: Passing large or complex data structures to threads

2013-05-27 Thread Joseph Rushton Wakeling
On 05/27/2013 11:33 PM, Simen Kjaeraas wrote: > A few questions: > > Why use a class? Will MyDataStore be subclassed? It was important to me that it have reference semantics, in particular that a = b implies a is b. > Will you have some instances of MyDataStore that will be mutated, and > others

Re: Passing large or complex data structures to threads

2013-05-27 Thread Simen Kjaeraas
On Mon, 27 May 2013 14:08:12 +0200, Joseph Rushton Wakeling wrote: On 05/26/2013 05:59 PM, Ali Çehreli wrote: On 05/26/2013 05:38 AM, Simen Kjaeraas wrote: Tuple!(size_t, size_t)[][] data = createData(); immutable dataImm = assumeUnique(data); data = null; // Simply to ensu

Re: Passing large or complex data structures to threads

2013-05-27 Thread Joseph Rushton Wakeling
On 05/26/2013 05:59 PM, Ali Çehreli wrote: > On 05/26/2013 05:38 AM, Simen Kjaeraas wrote: > > >> Tuple!(size_t, size_t)[][] data = createData(); >> immutable dataImm = assumeUnique(data); >> data = null; // Simply to ensure no mutable references exist. > > The last line is not ne

Re: Passing large or complex data structures to threads

2013-05-26 Thread Simen Kjaeraas
On Sun, 26 May 2013 17:59:32 +0200, Ali Çehreli wrote: On 05/26/2013 05:38 AM, Simen Kjaeraas wrote: > Tuple!(size_t, size_t)[][] data = createData(); > immutable dataImm = assumeUnique(data); > data = null; // Simply to ensure no mutable references exist. The last line is

Re: Passing large or complex data structures to threads

2013-05-26 Thread Ali Çehreli
On 05/26/2013 05:38 AM, Simen Kjaeraas wrote: > Tuple!(size_t, size_t)[][] data = createData(); > immutable dataImm = assumeUnique(data); > data = null; // Simply to ensure no mutable references exist. The last line is not needed. assumeUnique already does that. :) Ali

Re: Passing large or complex data structures to threads

2013-05-26 Thread John Colvin
On Sunday, 26 May 2013 at 12:08:41 UTC, Joseph Rushton Wakeling wrote: On 05/24/2013 05:59 PM, Ali Çehreli wrote: The following simple example uses mutable data but it should work with 'const' too. Limiting ourselves to read-only, won't there still be a slowdown caused by multiple threads try

Re: Passing large or complex data structures to threads

2013-05-26 Thread Simen Kjaeraas
On Sun, 26 May 2013 14:06:39 +0200, Joseph Rushton Wakeling wrote: On 05/24/2013 04:39 PM, Simen Kjaeraas wrote: First, *is* it read-only? If so, store it as immutable and enjoy free sharing. If not, how and why not? I can confess that it's as simple as feeling extremely uncomfortable deal

Re: Passing large or complex data structures to threads

2013-05-26 Thread Simen Kjaeraas
On Sun, 26 May 2013 14:06:39 +0200, Joseph Rushton Wakeling wrote: On 05/24/2013 04:39 PM, Simen Kjaeraas wrote: First, *is* it read-only? If so, store it as immutable and enjoy free sharing. If not, how and why not? I can confess that it's as simple as feeling extremely uncomfortable de

Re: Passing large or complex data structures to threads

2013-05-26 Thread Joseph Rushton Wakeling
On 05/24/2013 05:59 PM, Ali Çehreli wrote: > The following simple example uses mutable data but it should work with > 'const' too. Limiting ourselves to read-only, won't there still be a slowdown caused by multiple threads trying to access the same data? The particular case I have will involve c

Re: Passing large or complex data structures to threads

2013-05-26 Thread Joseph Rushton Wakeling
On 05/24/2013 04:39 PM, Simen Kjaeraas wrote: > First, *is* it read-only? If so, store it as immutable and enjoy free > sharing. If not, how and why not? I can confess that it's as simple as feeling extremely uncomfortable dealing with immutable where it relates to any kind of complex data structu

Re: Passing large or complex data structures to threads

2013-05-24 Thread Ali Çehreli
On 05/24/2013 06:26 AM, Joseph Rushton Wakeling wrote: > Are there any recommended strategies for passing large or complex data > structures (particularly reference types) to threads? std.concurrency works with shared data. > For the purpose of this discussion we can assume that it's read-only

Re: Passing large or complex data structures to threads

2013-05-24 Thread Simen Kjaeraas
On 2013-05-24, 15:26, Joseph Rushton Wakeling wrote: Hello all, Are there any recommended strategies for passing large or complex data structures (particularly reference types) to threads? For the purpose of this discussion we can assume that it's read-only data, so if we're talking about ju