On 18 April 2014 16:16, via Digitalmars-d <[email protected]>wrote:
> On Friday, 18 April 2014 at 00:11:28 UTC, H. S. Teoh via Digitalmars-d > wrote: > >> I thought that whole point of *A*RC is for the compiler to know when ref >> count updates can be skipped? Or are you saying this is algorithmically >> undecidable in the compiler? >> > > Multithreading cause major problems. A function owns the array passed as a > parameter, no ref counting needed, but if another thread is deleting > objects in the array then you cannot assume that ownership is transitive > and will have to inc/dec every object you look at. If it is thread local > then ownership is transitive and no inc/decs are needed in the function...? > > But how can you let the compiler know that you have protected the array so > only one thread will take processing-ownership during the life span of the > function call? > D pointers are thread-local by default, you need to mark things 'shared' explicitly if they are to be passed between threads. This is one of the great advantages D has over C/C++/Obj-C.
