Reference Counting Template
Lutger
lutger.blijdestijn at gmail.com
Mon Dec 14 09:39:41 PST 2009
Denis Koroskin wrote:
> 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.
Awesome, that means you can still write a fast(er) single-threaded version
of anything without the client even having to think about it!
More information about the Digitalmars-d
mailing list