修复退出时可能崩溃的BUG
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
#pragma once
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
#include "Export.h"
|
||||
#include <shared_mutex>
|
||||
#include "WebFileInfo.h"
|
||||
#include <unordered_map>
|
||||
|
||||
using std::chrono::operator""s;
|
||||
using std::chrono::operator""min;
|
||||
@@ -14,26 +12,9 @@ using std::chrono::operator""min;
|
||||
class UNSWSC_DLL_EXPORT TempFileManager
|
||||
{
|
||||
private:
|
||||
struct FileControlBlock
|
||||
{
|
||||
WebFileInfo info;
|
||||
std::chrono::steady_clock::time_point expire_time;
|
||||
std::chrono::steady_clock::time_point active_start_time;
|
||||
std::chrono::seconds remaining_timeout;
|
||||
std::chrono::seconds max_processing_timeout;
|
||||
bool is_active = false;
|
||||
bool is_permanent = false; // 是否永久保留
|
||||
bool is_invalid = false;
|
||||
};
|
||||
class Impl;
|
||||
|
||||
std::string base_dir;
|
||||
std::unordered_map<std::string, FileControlBlock> file_map;
|
||||
mutable std::shared_mutex rw_mutex;
|
||||
|
||||
// C++20 jthread
|
||||
std::jthread cleanup_thread;
|
||||
|
||||
void CleanupLoop(std::stop_token st) noexcept;
|
||||
std::unique_ptr<Impl> pimpl;
|
||||
|
||||
public:
|
||||
TempFileManager() noexcept;
|
||||
|
||||
Reference in New Issue
Block a user