Distributed Memory implementation
Dragos Carp via Digitalmars-d
digitalmars-d at puremagic.com
Tue Jan 19 04:13:26 PST 2016
On Tuesday, 19 January 2016 at 11:56:38 UTC, tcak wrote:
> On Tuesday, 19 January 2016 at 10:09:01 UTC, Ola Fosheim
> Grøstad wrote:
>> On Monday, 18 January 2016 at 05:59:15 UTC, tcak wrote:
>>> Is there anything like this in Phobos, or shall I start my
>>> own implementation?
>>
>> It isn't really clear to me what you are trying to do. IIRC
>> the C++ deque is usually implemented as an array of pointers
>> to fixed sized memory blocks.
>>
>> Is that what you are trying to achieve?
>
> First of all, I have started implementation, and a part of
> implementation is completed.
>
> For your question, I can explain it as follows:
>
> Example I have 3 memory blocks.
>
> Memory block 1: Ptr = 0x1000, Len = 100
> Memory block 2: Ptr = 0x2000, Len = 5
> Memory block 3: Ptr = 0x3000, Len = 150
>
> Into the class FragmentedMemory, you append those three memory
> blocks. Then it provides you an interface like those three
> memory blocks are consecutive.
>
> Let's say: fragmem[ 125 ] = 5;
>
> Because the index 125 is in memory block 3, the value is
> written to memoryBlock3[ 20 ];
> (125 = 100 + 5 + 20 )
>
> Reading is in the same way. I think you can think about use
> cases on your side.
>
> Currently, set, get, append operations are completed.
>
> I will implement bulk memory copy and assign operations as well.
If the number of blocks is known at compile time use chain [1],
otherwise use joiner [2].
At the moment joiner does not provide opIndex, opSlice, length
and such, but this can be fixed.
[1] http://dlang.org/phobos/std_range.html#.chain
[2] http://dlang.org/phobos/std_algorithm_iteration.html#joiner
More information about the Digitalmars-d
mailing list