add brute-force search command for game seeds that result in rare enemies
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <shared_mutex>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
@@ -102,3 +103,21 @@ private:
|
||||
std::unordered_map<std::string, std::shared_ptr<File>> name_to_file;
|
||||
uint64_t ttl_usecs;
|
||||
};
|
||||
|
||||
class ThreadSafeFileCache {
|
||||
public:
|
||||
explicit ThreadSafeFileCache() = default;
|
||||
ThreadSafeFileCache(const ThreadSafeFileCache&) = delete;
|
||||
ThreadSafeFileCache(ThreadSafeFileCache&&) = delete;
|
||||
ThreadSafeFileCache& operator=(const ThreadSafeFileCache&) = delete;
|
||||
ThreadSafeFileCache& operator=(ThreadSafeFileCache&&) = delete;
|
||||
~ThreadSafeFileCache() = default;
|
||||
|
||||
// Warning: generate() is called while the lock is held for writing, so it
|
||||
// will block other threads.
|
||||
std::shared_ptr<const std::string> get(const std::string& name, std::function<std::shared_ptr<const std::string>(const std::string&)> generate);
|
||||
|
||||
private:
|
||||
std::shared_mutex lock;
|
||||
std::unordered_map<std::string, std::shared_ptr<const std::string>> name_to_file;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user