AMFP Enhanced
C++ reference: the code this unofficial fork added
Loading...
Searching...
No Matches
LuxPreloader.h
Go to the documentation of this file.
1/*
2 * AMFP-2026: warms the OS file cache with the next map's files while the player is in this one
3 * (LuxPreload.h picks the files). A low-priority thread only reads files and drops the bytes:
4 * no engine or GL state is touched, so it is safe beside the game. Stopped before every load.
5 */
6#ifndef LUX_PRELOADER_H
7#define LUX_PRELOADER_H
8
9#include "LuxBase.h"
10#include <atomic>
11#include <thread>
12
14{
15public:
16 cLuxPreloader() : mbStop(false), mlFiles(0), mlBytes(0), mbFinished(false) {}
18
19 /** asMapFile: the current map's full path (its folder holds the next maps). */
20 void Start(const tWString& asMapFile, const tWString& asCacheFolder);
21 /** Stops and waits (a read stops within one 1 MB chunk); logs what was warmed. */
22 void Stop();
23
24private:
25 void Run(tWString asMapFile, tWString asCacheFolder);
26 std::thread mThread;
27 std::atomic<bool> mbStop;
28 std::atomic<int> mlFiles;
29 std::atomic<long long> mlBytes;
30 std::atomic<bool> mbFinished;
31 tString msMapName;
32};
33
34#endif
void Start(const tWString &asMapFile, const tWString &asCacheFolder)
asMapFile: the current map's full path (its folder holds the next maps).
void Stop()
Stops and waits (a read stops within one 1 MB chunk); logs what was warmed.