Reference Counting Template

Denis Koroskin 2korden at gmail.com
Mon Dec 14 01:41:53 PST 2009


On Mon, 14 Dec 2009 11:04:15 +0300, Lutger <lutger.blijdestijn at gmail.com>  
wrote:

> What are you planning to with multithreading?
>
> With the current type system, is it possible to statically detect inside  
> the
> template if the refcount is used in shared scenario's, and base the
> implementation on that information? That would be ideal, if it is indeed
> possible.
>
> std.stdio.File is refcounted, perhaps you can see to replace it's
> implementation with your template.
>
> Thanks you for this, I think it's great that D will have it  
> out-of-the-box.
> Managing resources in say C# or Java is a pain in the wrist.
>
>

In fact, multi-threading should be easy: shared versions of opAssign would  
use atomicIncrement(_counter), whereas thread-local would fallback to  
++_counter.



More information about the Digitalmars-d mailing list