2014-04-08 06:51:53 +00:00
|
|
|
#pragma once
|
2011-05-16 16:31:19 +00:00
|
|
|
|
2015-12-24 21:28:18 +00:00
|
|
|
#include <atomic>
|
2016-03-01 17:47:53 +00:00
|
|
|
#include <functional>
|
2015-12-24 21:28:18 +00:00
|
|
|
|
2011-05-16 16:31:19 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2016-02-16 16:39:39 +00:00
|
|
|
class ReadBuffer;
|
|
|
|
class WriteBuffer;
|
2021-05-26 20:37:44 +00:00
|
|
|
class Throttler;
|
|
|
|
|
|
|
|
using ThrottlerPtr = std::shared_ptr<Throttler>;
|
2016-02-16 16:39:39 +00:00
|
|
|
|
|
|
|
|
2021-05-27 12:54:47 +00:00
|
|
|
/// Copies data from ReadBuffer to WriteBuffer, all that is.
|
2011-05-16 16:31:19 +00:00
|
|
|
void copyData(ReadBuffer & from, WriteBuffer & to);
|
|
|
|
|
2021-05-27 12:54:47 +00:00
|
|
|
/// Copies `bytes` bytes from ReadBuffer to WriteBuffer. If there are no `bytes` bytes, then throws an exception.
|
2014-04-02 13:45:39 +00:00
|
|
|
void copyData(ReadBuffer & from, WriteBuffer & to, size_t bytes);
|
|
|
|
|
2021-05-27 12:54:47 +00:00
|
|
|
/// The same, with the condition to cancel.
|
2018-05-25 11:45:19 +00:00
|
|
|
void copyData(ReadBuffer & from, WriteBuffer & to, const std::atomic<int> & is_cancelled);
|
|
|
|
void copyData(ReadBuffer & from, WriteBuffer & to, size_t bytes, const std::atomic<int> & is_cancelled);
|
2015-12-24 21:28:18 +00:00
|
|
|
|
2016-03-01 17:47:53 +00:00
|
|
|
void copyData(ReadBuffer & from, WriteBuffer & to, std::function<void()> cancellation_hook);
|
|
|
|
void copyData(ReadBuffer & from, WriteBuffer & to, size_t bytes, std::function<void()> cancellation_hook);
|
2015-12-24 21:28:18 +00:00
|
|
|
|
2021-05-27 12:54:47 +00:00
|
|
|
/// Same as above but also use throttler to limit maximum speed
|
|
|
|
void copyDataWithThrottler(ReadBuffer & from, WriteBuffer & to, const std::atomic<int> & is_cancelled, ThrottlerPtr throttler);
|
|
|
|
void copyDataWithThrottler(ReadBuffer & from, WriteBuffer & to, size_t bytes, const std::atomic<int> & is_cancelled, ThrottlerPtr throttler);
|
|
|
|
|
2011-05-16 16:31:19 +00:00
|
|
|
}
|