updated build system
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
This commit is contained in:
@ -23,6 +23,7 @@
|
||||
#define REPERTORY_INCLUDE_UTILS_FILE_THREAD_FILE_HPP_
|
||||
|
||||
#include "utils/file.hpp"
|
||||
#include <memory>
|
||||
|
||||
namespace repertory::utils::file {
|
||||
class thread_file final : public i_file {
|
||||
@ -67,11 +68,44 @@ public:
|
||||
thread_file(thread_file &&move_file) noexcept
|
||||
: file_(std::move(move_file.file_)) {}
|
||||
|
||||
~thread_file() override { close(); }
|
||||
~thread_file() override;
|
||||
|
||||
private:
|
||||
using action_t = std::function<bool()>;
|
||||
|
||||
struct io_item final {
|
||||
action_t action;
|
||||
bool complete{false};
|
||||
std::unique_ptr<std::mutex> mtx{
|
||||
std::make_unique<std::mutex>(),
|
||||
};
|
||||
mutable std::unique_ptr<std::condition_variable> notify{
|
||||
std::make_unique<std::condition_variable>(),
|
||||
};
|
||||
bool success{false};
|
||||
|
||||
void done(bool result);
|
||||
|
||||
void wait() const;
|
||||
};
|
||||
|
||||
private:
|
||||
fs_file_t file_;
|
||||
|
||||
private:
|
||||
mutable std::vector<io_item *> actions_;
|
||||
mutable std::unique_ptr<std::thread> io_thread_;
|
||||
mutable std::unique_ptr<std::mutex> mtx_{std::make_unique<std::mutex>()};
|
||||
mutable std::unique_ptr<std::condition_variable> notify_{
|
||||
std::make_unique<std::condition_variable>(),
|
||||
};
|
||||
stop_type stop_requested_{false};
|
||||
|
||||
private:
|
||||
auto do_io(action_t action) const -> bool;
|
||||
|
||||
void thread_func() const;
|
||||
|
||||
public:
|
||||
void close() override;
|
||||
|
||||
|
Reference in New Issue
Block a user