I have simplified my problem which can be seen below.

import std.stdio;
import vibe.core.core;
import vibe.core.concurrency;
import vibe.data.json;

void main()
{
    int[] list;

    bool ListManipulator(ref int[] list)
    {
        list ~= 2;
        list ~= 4;
        return true;
    }

    bool ListManipulatorPointer( int[]* list)
    {
        *list ~= 2;
        *list ~= 4;
        return true;
    }


auto future = vibe.core.concurrency.async(&ListManipulator, list);
    future.getResult();

    writeln(list); ----> prints empty list

future = vibe.core.concurrency.async(&ListManipulatorPointer, &list);
    future.getResult();

    writeln(list); ----> prints [2,4]
}


Why passing the pointer works meanwhile passing as reference does nothing? I feel that is more D issue than vibe.d which I can learn something I hope.

Erdem



Reply via email to