|
/********************************************************************
|
|
* CONFIDENTIAL - All source code is the propriety and confidential *
|
|
* information of David Sorber. *
|
|
* *
|
|
* Copyright 2024 David Sorber *
|
|
* Unpublished -- all rights reserved under the copyright laws *
|
|
* of the United States. *
|
|
********************************************************************/
|
|
|
|
#ifndef __COPYTOOL_COPYMANAGER_H_
|
|
#define __COPYTOOL_COPYMANAGER_H_
|
|
|
|
#include <atomic>
|
|
#include <cstdint>
|
|
#include <filesystem>
|
|
#include <map>
|
|
#include <string>
|
|
#include <thread>
|
|
#include <vector>
|
|
|
|
#include "CopyManagerOptions.h"
|
|
#include "ProtectedQueue.h"
|
|
|
|
namespace sfs = std::filesystem;
|
|
|
|
|
|
namespace DBS
|
|
{
|
|
|
|
class CopyManager
|
|
{
|
|
public:
|
|
|
|
// Maximum "count" size per sendfile() documentation
|
|
static inline size_t MAX_COPY_SIZE{0x7ffff000};
|
|
|
|
static inline const sfs::directory_entry ENTRY_TERMINATOR{};
|
|
|
|
CopyManager(CopyManagerOptions& options);
|
|
|
|
~CopyManager();
|
|
|
|
int run();
|
|
|
|
private:
|
|
|
|
void mainThreadBody();
|
|
|
|
void copyThreadBody();
|
|
|
|
|
|
CopyManagerOptions& r_options;
|
|
|
|
ProtectedQueue<sfs::directory_entry> m_entryQueue;
|
|
std::atomic_bool m_terminate;
|
|
|
|
std::thread* p_mainThread;
|
|
std::vector<std::thread*> m_copyThreads;
|
|
|
|
};
|
|
|
|
} // namespace DBS
|
|
|
|
|
|
#endif //__COPYTOOL_COPYMANAGER_H_
|