Project

General

Profile

« Previous | Next » 

Revision 6248f75f

Added by david.sorber over 2 years ago

Add progress bar; version: 0.2.0.

View differences:

src/CopyManager.h
#include <cstdint>
#include <filesystem>
#include <map>
#include <mutex>
#include <string>
#include <thread>
#include <vector>
......
static inline const sfs::directory_entry ENTRY_TERMINATOR{};
CopyManager() = delete;
CopyManager(CopyManagerOptions& options);
~CopyManager();
int run();
/**
* Execute the copy operation described by the CopyManagerOptions instance.
* @return
*/
void run();
/**
* Wait for the main thread to complete. Should be called after run().
* @return
*/
int waitForComplete();
inline bool isRunning() const
{
return m_running;
}
inline uint64_t getTotalEntries()
{
return m_totalEntries;
}
inline uint64_t getInvalidEntries()
{
return m_invalidEntries;
}
inline uint64_t getProcessedEntries()
{
return m_processedEntries;
}
//--- Setters -------------------------------------------------------------
inline void incTotalEntries()
{
++m_totalEntries;
}
inline void incInvalidEntries()
{
++m_invalidEntries;
}
inline void incProcessedEntries()
{
++m_processedEntries;
}
private:
/**
* Body of the main thread spawned when run() is called.
*/
void mainThreadBody();
/**
* Body of thread that does the actual copying and creating of directories.
*/
void copyThreadBody();
/**
* Body of thread that counts directory entries in the source path.
*/
void counterThreadBody();
CopyManagerOptions& r_options;
ProtectedQueue<sfs::directory_entry> m_entryQueue;
std::atomic_bool m_terminate;
std::atomic_bool m_running;
std::thread* p_mainThread;
std::vector<std::thread*> m_copyThreads;
std::thread* p_counterThread;
std::mutex m_mutex;
std::atomic_uint64_t m_totalEntries;
std::atomic_uint64_t m_invalidEntries;
std::atomic_uint64_t m_processedEntries;
};

Also available in: Unified diff