From 6b9534cad8406c820e1517481b49113e4affc01c Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Wed, 14 Apr 2021 23:15:31 +0300 Subject: [PATCH] Add copyData() with std::atomic and progress callback --- src/DataStreams/copyData.cpp | 10 ++++++++++ src/DataStreams/copyData.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/src/DataStreams/copyData.cpp b/src/DataStreams/copyData.cpp index a0651999034..a26052778a8 100644 --- a/src/DataStreams/copyData.cpp +++ b/src/DataStreams/copyData.cpp @@ -49,6 +49,16 @@ void copyDataImpl(IBlockInputStream & from, IBlockOutputStream & to, TCancelCall to.writeSuffix(); } +void copyData(IBlockInputStream & from, IBlockOutputStream & to, const std::function & progress, + std::atomic * is_cancelled) +{ + auto is_cancelled_pred = [is_cancelled] () + { + return isAtomicSet(is_cancelled); + }; + + copyDataImpl(from, to, is_cancelled_pred, progress); +} inline void doNothing(const Block &) {} diff --git a/src/DataStreams/copyData.h b/src/DataStreams/copyData.h index f2bce8f411b..3dc90aed37d 100644 --- a/src/DataStreams/copyData.h +++ b/src/DataStreams/copyData.h @@ -16,6 +16,9 @@ class Block; */ void copyData(IBlockInputStream & from, IBlockOutputStream & to, std::atomic * is_cancelled = nullptr); +void copyData(IBlockInputStream & from, IBlockOutputStream & to, const std::function & progress, + std::atomic * is_cancelled = nullptr); + void copyData(IBlockInputStream & from, IBlockOutputStream & to, const std::function & is_cancelled); void copyData(IBlockInputStream & from, IBlockOutputStream & to, const std::function & is_cancelled,