You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
77 lines
2.1 KiB
C++
77 lines
2.1 KiB
C++
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
/**
|
|
* DDC Filesystem Cache cleanup thread.
|
|
*/
|
|
class FDDCCleanup : public FRunnable
|
|
{
|
|
/** Singleton instance */
|
|
static FDDCCleanup* Runnable;
|
|
|
|
/** Thread to run the cleanup FRunnable on */
|
|
FRunnableThread* Thread;
|
|
/** > 0 if we've been asked to abort work in progress at the next opportunity */
|
|
FThreadSafeCounter StopTaskCounter;
|
|
/** List of filesystems to clean up */
|
|
TArray< TSharedPtr< struct FFilesystemInfo > > CleanupList;
|
|
/** Synchronization object */
|
|
FCriticalSection DataLock;
|
|
|
|
/** Constructor */
|
|
FDDCCleanup();
|
|
|
|
/** Destructor */
|
|
virtual ~FDDCCleanup();
|
|
|
|
// Begin FRunnable interface.
|
|
virtual bool Init();
|
|
virtual uint32 Run();
|
|
virtual void Stop();
|
|
virtual void Exit();
|
|
// End FRunnable interface
|
|
|
|
/** Checks if there's been any Stop requests */
|
|
FORCEINLINE bool ShouldStop() const
|
|
{
|
|
return StopTaskCounter.GetValue() > 0;
|
|
}
|
|
|
|
/**
|
|
* Waits for a given amount of time periodically checking if there's been any Stop requests.
|
|
*
|
|
* @param InSeconds time in seconds to wait.
|
|
* @param InSleepTime interval at which to check for Stop requests.
|
|
*/
|
|
void Wait( const float InSeconds, const float InSleepTime = 0.1f );
|
|
|
|
/**
|
|
* Performs directory cleanup.
|
|
*
|
|
* @param FilesystemInfo Filesystem to cleanup.
|
|
* @return true if the filesystem contained any directories to clean up, false otherwise.
|
|
*/
|
|
bool CleanupFilesystemDirectory( TSharedPtr< FFilesystemInfo > FilesystemInfo );
|
|
|
|
/** Makes sure this thread has stopped properly */
|
|
void EnsureCompletion();
|
|
|
|
public:
|
|
|
|
/**
|
|
* Adds DDC filesystem to clean up.
|
|
*
|
|
* @param InCachePath Filesystem path.
|
|
* @param InDaysToDelete Number of days since last access time to consider a file as unused.
|
|
* @param InMaxContinuousFileChecks Number of files to check without pausing.
|
|
*/
|
|
void AddFilesystem( FString& InCachePath, int32 InDaysToDelete, int32 InMaxNumFoldersToCheck, int32 InMaxContinuousFileChecks );
|
|
|
|
/** Gets DDC Cleanup singleton instance */
|
|
static FDDCCleanup* Get();
|
|
|
|
/** Shuts down DDC Cleanup thread. */
|
|
static void Shutdown();
|
|
};
|