From b68d23f5159de0daf8de497e089a7131c99ea446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Mon, 30 Oct 2017 22:56:51 +0100 Subject: [PATCH] Add opCast(bool) to FreeListRef and remove opAssign with value type. --- source/vibe/core/concurrency.d | 2 +- source/vibe/internal/freelistref.d | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source/vibe/core/concurrency.d b/source/vibe/core/concurrency.d index 60a7dd4..05b4c42 100644 --- a/source/vibe/core/concurrency.d +++ b/source/vibe/core/concurrency.d @@ -1143,7 +1143,7 @@ Future!(ReturnType!CALLABLE) async(CALLABLE, ARGS...)(CALLABLE callable, ARGS ar Future!RET ret; ret.init(); static void compute(FreeListRef!(shared(RET)) dst, CALLABLE callable, ARGS args) { - dst = cast(shared(RET))callable(args); + dst.get = cast(shared(RET))callable(args); } static if (isWeaklyIsolated!CALLABLE && isWeaklyIsolated!ARGS) { ret.m_task = runWorkerTaskH(&compute, ret.m_result, callable, args); diff --git a/source/vibe/internal/freelistref.d b/source/vibe/internal/freelistref.d index 216e3f3..5820da9 100644 --- a/source/vibe/internal/freelistref.d +++ b/source/vibe/internal/freelistref.d @@ -133,6 +133,8 @@ struct FreeListRef(T, bool INIT = true) } } + bool opCast(T)() const if (is(T == bool)) { return m_object !is null; } + void opAssign(FreeListRef other) { clear(); @@ -159,7 +161,6 @@ struct FreeListRef(T, bool INIT = true) @property inout(T) get() inout @safe nothrow { return m_object; } } else { @property ref inout(T) get() inout @safe nothrow { return *m_object; } - void opAssign(T t) { *m_object = t; } } alias get this;