On 14/12/2017 3:57 AM, IM wrote:

snip

    - Is this the idiomatic way to define a singleton in D?: https://gitlab.com/3d_immortal/libdtasks/blob/master/src/tasks/TaskSystem.d#L24.

You say singleton I think wrong.

Use free-functions and globals instead.

Singletons are always a code smell that OOP based languages like to say are a 'good thing'.

e.g.

module taskmgr;
import task;

private __gshared {
        Task[] tasks;
}

Task[] getTasks() {
        return tasks;
}

void clearTasks() {
        tasks = null;
}

void addTask(Task t) {
        tasks ~= t;
}

Reply via email to