openMSX
PreCacheFile.hh
Go to the documentation of this file.
1 #ifndef PRECACHEFILE_HH
2 #define PRECACHEFILE_HH
3 
4 #include <atomic>
5 #include <string>
6 #include <thread>
7 
8 namespace openmsx {
9 
10 /**
11  * Read the complete file once and discard result. Hopefully the file
12  * sticks in the OS cache. Mainly useful to avoid CDROM spinups or to
13  * speed up real floppy disk (/dev/fd0) reads.
14  */
15 class PreCacheFile final
16 {
17 public:
18  explicit PreCacheFile(std::string name);
19  ~PreCacheFile();
20 
21 private:
22  void run();
23 
24  const std::string name;
25  std::thread thread;
26  std::atomic<bool> exitLoop;
27 };
28 
29 } // namespace openmsx
30 
31 #endif
bool getEnum() const noexcept
Definition: EnumSetting.hh:96
PreCacheFile(std::string name)
Definition: PreCacheFile.cc:9