Skip to content
Snippets Groups Projects
Commit 239790e4 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Trend: changed to Task::doAsync()

parent daa9687e
No related branches found
No related tags found
1 merge request!222M214003/develop
......@@ -209,35 +209,6 @@ public:
}
}
struct FuncArgs
{
FieldVector3D &work;
FieldVector3D &fields3D;
std::vector<RecordInfo> &recordList;
int t{ 0 };
double zj{ 0 };
FuncArgs(FieldVector3D &_work, FieldVector3D &_fields3D, std::vector<RecordInfo> &_recordList)
: work(_work), fields3D(_fields3D), recordList(_recordList)
{
}
void
set(int _t, double _zj)
{
t = _t;
zj = _zj;
}
};
static void *
records_calc_trend_sum_func(void *_args)
{
FuncArgs *args = (FuncArgs *) _args;
records_calc_trend_sum(args->work, args->fields3D[args->t], args->recordList, args->zj);
return nullptr;
}
void
run_async()
{
......@@ -258,7 +229,6 @@ public:
bool useTask = true;
cdo::Task task;
FuncArgs funcArgs(work, fields3D, recordList);
int tsID = 0;
while (true)
......@@ -281,17 +251,13 @@ public:
cdo_read_record(streamID1, fields3D[tsID % 2][varID][levelID]);
}
if (useTask)
{
if (tsID > 0) task.wait();
funcArgs.set(tsID % 2, zj);
task.start(records_calc_trend_sum_func, &funcArgs);
}
else
{
funcArgs.set(tsID % 2, zj);
records_calc_trend_sum_func(&funcArgs);
}
if (useTask && tsID > 0) task.wait();
std::function<void()> records_calc_trend_sum_func
= std::bind(records_calc_trend_sum, std::ref(work), std::ref(fields3D[tsID % 2]), std::cref(recordList), zj);
if (useTask) { task.doAsync(records_calc_trend_sum_func); }
else { records_calc_trend_sum_func(); }
tsID++;
}
......@@ -305,8 +271,8 @@ public:
void
run() override
{
auto doRunAsync = (Options::CDO_Parallel_Read > 0);
if (doRunAsync)
auto runAsync = (Options::CDO_Parallel_Read > 0);
if (runAsync)
run_async();
else
run_sync();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment