From 3146d14431c10a26fa85f0ff036bcbd89cbc628b Mon Sep 17 00:00:00 2001 From: cxl Date: Mon, 6 Apr 2020 20:20:33 +0000 Subject: [PATCH] Core: CoDo_ST - diagnostic ST variant of CoDo git-svn-id: svn://ultimatepp.org/upp/trunk@14262 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/CoWork.h | 6 ++++++ uppsrc/Core/src.tpp/CoWork_en-us.tpp | 14 ++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/uppsrc/Core/CoWork.h b/uppsrc/Core/CoWork.h index 903db784e..439876fd3 100644 --- a/uppsrc/Core/CoWork.h +++ b/uppsrc/Core/CoWork.h @@ -125,6 +125,12 @@ void CoDo(Function&& fn) co * fn; } +inline +void CoDo_ST(Function&& fn) +{ + fn(); +} + template void CoFor(int n, Fn iterator) { diff --git a/uppsrc/Core/src.tpp/CoWork_en-us.tpp b/uppsrc/Core/src.tpp/CoWork_en-us.tpp index 0f9731693..915c37cf3 100644 --- a/uppsrc/Core/src.tpp/CoWork_en-us.tpp +++ b/uppsrc/Core/src.tpp/CoWork_en-us.tpp @@ -191,10 +191,9 @@ nt]_[*@3 n])&] [s2;%% This simple helper class just removes `"noexcept(false)`" from CoWork destructor, removing exception throws from the destructor and allowing it to be used as member variable. Obviously, if -exception handling is required, you need to use Finish (not depend -on destructor to call it).&] -[s0; &] -[s0; &] +exception handling is required, you need to use Finish (not to +depend on destructor to call it).&] +[s3; &] [ {{10000@(113.42.0) [s0;%% [*@7;4 Loop parallelisation functions]]}}&] [s3; &] [s5;:Upp`:`:CoDo`(Upp`:`:Function``&`&`): [@(0.0.255) void]_[* CoDo]([_^Upp`:`:Function^ F @@ -203,6 +202,13 @@ unction]<[@(0.0.255) void]_()>`&`&_[*@3 fn])&] effective way to parallelise iteration.&] [s3;%% &] [s4; &] +[s5;:Upp`:`:CoDo`_ST`(Upp`:`:Function``&`&`): [@(0.0.255) void]_[* CoDo`_ST]([_^Upp`:`:Function^ F +unction]<[@(0.0.255) void]_()>`&`&_[*@3 fn])&] +[s2;%% This function simply calls [%-*@3 fn]. It is diagnostics tool +`- it allows to change CoDo parallel iteration into serial one +by adding `"`_ST`" text.&] +[s3;%% &] +[s4; &] [s5;:Upp`:`:CoFor`(int`,Fn`): [@(0.0.255) template]_<[@(0.0.255) typename]_[*@4 Fn]>_[@(0.0.255) v oid]_[* CoFor]([@(0.0.255) int]_[*@3 n], [*@4 Fn]_[*@3 iterator])&] [s2;%% Based on CoDo, runs in parallel [%-*@3 iterator] for values