This commit is contained in:
@ -22,7 +22,7 @@
|
|||||||
#ifndef REPERTORY_INCLUDE_FILE_MANAGER_DIRECT_OPEN_FILE_HPP_
|
#ifndef REPERTORY_INCLUDE_FILE_MANAGER_DIRECT_OPEN_FILE_HPP_
|
||||||
#define REPERTORY_INCLUDE_FILE_MANAGER_DIRECT_OPEN_FILE_HPP_
|
#define REPERTORY_INCLUDE_FILE_MANAGER_DIRECT_OPEN_FILE_HPP_
|
||||||
|
|
||||||
#include "file_manager/ring_buffer_common.hpp"
|
#include "file_manager/ring_buffer_base.hpp"
|
||||||
|
|
||||||
#include "types/repertory.hpp"
|
#include "types/repertory.hpp"
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ namespace repertory {
|
|||||||
class i_provider;
|
class i_provider;
|
||||||
class i_upload_manager;
|
class i_upload_manager;
|
||||||
|
|
||||||
class direct_open_file final : public ring_buffer_common {
|
class direct_open_file final : public ring_buffer_base {
|
||||||
public:
|
public:
|
||||||
direct_open_file(std::uint64_t chunk_size, std::uint8_t chunk_timeout,
|
direct_open_file(std::uint64_t chunk_size, std::uint8_t chunk_timeout,
|
||||||
filesystem_item fsi, i_provider &provider);
|
filesystem_item fsi, i_provider &provider);
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#ifndef REPERTORY_INCLUDE_FILE_MANAGER_RING_BUFFER_COMMON_HPP_
|
#ifndef REPERTORY_INCLUDE_FILE_MANAGER_RING_BUFFER_BASE_HPP_
|
||||||
#define REPERTORY_INCLUDE_FILE_MANAGER_RING_BUFFER_COMMON_HPP_
|
#define REPERTORY_INCLUDE_FILE_MANAGER_RING_BUFFER_BASE_HPP_
|
||||||
|
|
||||||
#include "file_manager/open_file_base.hpp"
|
#include "file_manager/open_file_base.hpp"
|
||||||
|
|
||||||
@ -31,22 +31,21 @@ namespace repertory {
|
|||||||
class i_provider;
|
class i_provider;
|
||||||
class i_upload_manager;
|
class i_upload_manager;
|
||||||
|
|
||||||
class ring_buffer_common : public open_file_base {
|
class ring_buffer_base : public open_file_base {
|
||||||
public:
|
public:
|
||||||
ring_buffer_common(std::uint64_t chunk_size, std::uint8_t chunk_timeout,
|
ring_buffer_base(std::uint64_t chunk_size, std::uint8_t chunk_timeout,
|
||||||
filesystem_item fsi, i_provider &provider,
|
filesystem_item fsi, i_provider &provider,
|
||||||
std::size_t ring_size, bool disable_io);
|
std::size_t ring_size, bool disable_io);
|
||||||
|
|
||||||
~ring_buffer_common() override = default;
|
~ring_buffer_base() override = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ring_buffer_common() = delete;
|
ring_buffer_base() = delete;
|
||||||
ring_buffer_common(const ring_buffer_common &) noexcept = delete;
|
ring_buffer_base(const ring_buffer_base &) noexcept = delete;
|
||||||
ring_buffer_common(ring_buffer_common &&) noexcept = delete;
|
ring_buffer_base(ring_buffer_base &&) noexcept = delete;
|
||||||
|
auto operator=(ring_buffer_base &&) noexcept -> ring_buffer_base & = delete;
|
||||||
auto
|
auto
|
||||||
operator=(ring_buffer_common &&) noexcept -> ring_buffer_common & = delete;
|
operator=(const ring_buffer_base &) noexcept -> ring_buffer_base & = delete;
|
||||||
auto operator=(const ring_buffer_common &) noexcept -> ring_buffer_common & =
|
|
||||||
delete;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static constexpr const auto min_ring_size{5U};
|
static constexpr const auto min_ring_size{5U};
|
||||||
@ -148,4 +147,4 @@ public:
|
|||||||
};
|
};
|
||||||
} // namespace repertory
|
} // namespace repertory
|
||||||
|
|
||||||
#endif // REPERTORY_INCLUDE_FILE_MANAGER_RING_BUFFER_COMMON_HPP_
|
#endif // REPERTORY_INCLUDE_FILE_MANAGER_RING_BUFFER_BASE_HPP_
|
@ -22,7 +22,7 @@
|
|||||||
#ifndef REPERTORY_INCLUDE_FILE_MANAGER_RING_BUFFER_OPEN_FILE_HPP_
|
#ifndef REPERTORY_INCLUDE_FILE_MANAGER_RING_BUFFER_OPEN_FILE_HPP_
|
||||||
#define REPERTORY_INCLUDE_FILE_MANAGER_RING_BUFFER_OPEN_FILE_HPP_
|
#define REPERTORY_INCLUDE_FILE_MANAGER_RING_BUFFER_OPEN_FILE_HPP_
|
||||||
|
|
||||||
#include "file_manager/ring_buffer_common.hpp"
|
#include "file_manager/ring_buffer_base.hpp"
|
||||||
|
|
||||||
#include "types/repertory.hpp"
|
#include "types/repertory.hpp"
|
||||||
#include "utils/file.hpp"
|
#include "utils/file.hpp"
|
||||||
@ -31,7 +31,7 @@ namespace repertory {
|
|||||||
class i_provider;
|
class i_provider;
|
||||||
class i_upload_manager;
|
class i_upload_manager;
|
||||||
|
|
||||||
class ring_buffer_open_file final : public ring_buffer_common {
|
class ring_buffer_open_file final : public ring_buffer_base {
|
||||||
public:
|
public:
|
||||||
ring_buffer_open_file(std::string buffer_directory, std::uint64_t chunk_size,
|
ring_buffer_open_file(std::string buffer_directory, std::uint64_t chunk_size,
|
||||||
std::uint8_t chunk_timeout, filesystem_item fsi,
|
std::uint8_t chunk_timeout, filesystem_item fsi,
|
||||||
|
@ -29,7 +29,7 @@ namespace repertory {
|
|||||||
direct_open_file::direct_open_file(std::uint64_t chunk_size,
|
direct_open_file::direct_open_file(std::uint64_t chunk_size,
|
||||||
std::uint8_t chunk_timeout,
|
std::uint8_t chunk_timeout,
|
||||||
filesystem_item fsi, i_provider &provider)
|
filesystem_item fsi, i_provider &provider)
|
||||||
: ring_buffer_common(chunk_size, chunk_timeout, fsi, provider,
|
: ring_buffer_base(chunk_size, chunk_timeout, fsi, provider,
|
||||||
min_ring_size, true) {}
|
min_ring_size, true) {}
|
||||||
|
|
||||||
direct_open_file::~direct_open_file() {
|
direct_open_file::~direct_open_file() {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include "file_manager/ring_buffer_common.hpp"
|
#include "file_manager/ring_buffer_base.hpp"
|
||||||
|
|
||||||
#include "events/event_system.hpp"
|
#include "events/event_system.hpp"
|
||||||
#include "file_manager/events.hpp"
|
#include "file_manager/events.hpp"
|
||||||
@ -31,7 +31,7 @@
|
|||||||
#include "utils/error_utils.hpp"
|
#include "utils/error_utils.hpp"
|
||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
ring_buffer_common::ring_buffer_common(std::uint64_t chunk_size,
|
ring_buffer_base::ring_buffer_base(std::uint64_t chunk_size,
|
||||||
std::uint8_t chunk_timeout,
|
std::uint8_t chunk_timeout,
|
||||||
filesystem_item fsi,
|
filesystem_item fsi,
|
||||||
i_provider &provider,
|
i_provider &provider,
|
||||||
@ -58,7 +58,7 @@ ring_buffer_common::ring_buffer_common(std::uint64_t chunk_size,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ring_buffer_common::check_start() -> api_error {
|
auto ring_buffer_base::check_start() -> api_error {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -79,7 +79,7 @@ auto ring_buffer_common::check_start() -> api_error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ring_buffer_common::close() -> bool {
|
auto ring_buffer_base::close() -> bool {
|
||||||
stop_requested_ = true;
|
stop_requested_ = true;
|
||||||
|
|
||||||
unique_mutex_lock chunk_lock(chunk_mtx_);
|
unique_mutex_lock chunk_lock(chunk_mtx_);
|
||||||
@ -96,7 +96,7 @@ auto ring_buffer_common::close() -> bool {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ring_buffer_common::download_chunk(std::size_t chunk,
|
auto ring_buffer_base::download_chunk(std::size_t chunk,
|
||||||
bool skip_active) -> api_error {
|
bool skip_active) -> api_error {
|
||||||
unique_mutex_lock chunk_lock(chunk_mtx_);
|
unique_mutex_lock chunk_lock(chunk_mtx_);
|
||||||
const auto unlock_and_notify = [this, &chunk_lock]() {
|
const auto unlock_and_notify = [this, &chunk_lock]() {
|
||||||
@ -173,21 +173,21 @@ auto ring_buffer_common::download_chunk(std::size_t chunk,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ring_buffer_common::forward(std::size_t count) {
|
void ring_buffer_base::forward(std::size_t count) {
|
||||||
update_position(count, true);
|
update_position(count, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ring_buffer_common::get_read_state() const -> boost::dynamic_bitset<> {
|
auto ring_buffer_base::get_read_state() const -> boost::dynamic_bitset<> {
|
||||||
recur_mutex_lock file_lock(get_mutex());
|
recur_mutex_lock file_lock(get_mutex());
|
||||||
return ring_state_;
|
return ring_state_;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ring_buffer_common::get_read_state(std::size_t chunk) const -> bool {
|
auto ring_buffer_base::get_read_state(std::size_t chunk) const -> bool {
|
||||||
recur_mutex_lock file_lock(get_mutex());
|
recur_mutex_lock file_lock(get_mutex());
|
||||||
return ring_state_[chunk % ring_state_.size()];
|
return ring_state_[chunk % ring_state_.size()];
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ring_buffer_common::read(std::size_t read_size, std::uint64_t read_offset,
|
auto ring_buffer_base::read(std::size_t read_size, std::uint64_t read_offset,
|
||||||
data_buffer &data) -> api_error {
|
data_buffer &data) -> api_error {
|
||||||
if (is_directory()) {
|
if (is_directory()) {
|
||||||
return api_error::invalid_operation;
|
return api_error::invalid_operation;
|
||||||
@ -254,7 +254,7 @@ auto ring_buffer_common::read(std::size_t read_size, std::uint64_t read_offset,
|
|||||||
return stop_requested_ ? api_error::download_stopped : res;
|
return stop_requested_ ? api_error::download_stopped : res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ring_buffer_common::reader_thread() {
|
void ring_buffer_base::reader_thread() {
|
||||||
unique_mutex_lock chunk_lock(chunk_mtx_);
|
unique_mutex_lock chunk_lock(chunk_mtx_);
|
||||||
auto next_chunk = ring_pos_;
|
auto next_chunk = ring_pos_;
|
||||||
chunk_notify_.notify_all();
|
chunk_notify_.notify_all();
|
||||||
@ -295,11 +295,11 @@ void ring_buffer_common::reader_thread() {
|
|||||||
get_api_path(), get_source_path(), api_error::download_stopped);
|
get_api_path(), get_source_path(), api_error::download_stopped);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ring_buffer_common::reverse(std::size_t count) {
|
void ring_buffer_base::reverse(std::size_t count) {
|
||||||
update_position(count, false);
|
update_position(count, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ring_buffer_common::set(std::size_t first_chunk,
|
void ring_buffer_base::set(std::size_t first_chunk,
|
||||||
std::size_t current_chunk) {
|
std::size_t current_chunk) {
|
||||||
mutex_lock chunk_lock(chunk_mtx_);
|
mutex_lock chunk_lock(chunk_mtx_);
|
||||||
if (first_chunk >= total_chunks_) {
|
if (first_chunk >= total_chunks_) {
|
||||||
@ -323,13 +323,13 @@ void ring_buffer_common::set(std::size_t first_chunk,
|
|||||||
chunk_notify_.notify_all();
|
chunk_notify_.notify_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ring_buffer_common::set_api_path(const std::string &api_path) {
|
void ring_buffer_base::set_api_path(const std::string &api_path) {
|
||||||
mutex_lock chunk_lock(chunk_mtx_);
|
mutex_lock chunk_lock(chunk_mtx_);
|
||||||
open_file_base::set_api_path(api_path);
|
open_file_base::set_api_path(api_path);
|
||||||
chunk_notify_.notify_all();
|
chunk_notify_.notify_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ring_buffer_common::update_position(std::size_t count, bool is_forward) {
|
void ring_buffer_base::update_position(std::size_t count, bool is_forward) {
|
||||||
mutex_lock chunk_lock(chunk_mtx_);
|
mutex_lock chunk_lock(chunk_mtx_);
|
||||||
|
|
||||||
if (is_forward) {
|
if (is_forward) {
|
@ -36,7 +36,7 @@ ring_buffer_open_file::ring_buffer_open_file(std::string buffer_directory,
|
|||||||
filesystem_item fsi,
|
filesystem_item fsi,
|
||||||
i_provider &provider,
|
i_provider &provider,
|
||||||
std::size_t ring_size)
|
std::size_t ring_size)
|
||||||
: ring_buffer_common(chunk_size, chunk_timeout, fsi, provider, ring_size,
|
: ring_buffer_base(chunk_size, chunk_timeout, fsi, provider, ring_size,
|
||||||
false),
|
false),
|
||||||
ring_state_(ring_size),
|
ring_state_(ring_size),
|
||||||
source_path_(utils::path::combine(buffer_directory,
|
source_path_(utils::path::combine(buffer_directory,
|
||||||
|
Reference in New Issue
Block a user