polserver/pol-core/bscript/compiler/file/SourceFileCache.h
Kevin Eady 62a252ad3a
Add daemon watch mode to ecompile (#630)
* Add libefsw at 3419347

* saving work

* some cleanup

* move to fs::paths

* saving work.. maybe hitting a limit with number of watched dirs?

* migrate to watching only ecompile.cfg specified folders, cleanup/doc

* Display summary between compilations in watch mode; fix cache reuse

* Fix inf loop; some cmake, format changes...

* some windows compilation fixes... tweaks to windows cmake?

* Update Efsw.cmake for build lib changes

* removed debug flag

* silence efsw build
dont add antlr project if it already exists

* Address review comments:
- use std::move on efswwatcher add_*

* add docs

* Add WatchModeByDefault ecompile.cfg option

* iniital work on tests

* Add CI actions

* some changes (passes locally on win, mac, linux)

* Fix fixtures dependency; use ecompile verbose mode

* Add core-changes

* Send ctrl+c instead of killing process

* Proper Python file naming

* Kill ecompile process on windows, SIGINT otherwise

---------

Co-authored-by: turleypol <turley@polserver.com>
2024-03-16 00:08:06 +01:00

39 lines
780 B
C++

#ifndef POLSERVER_SOURCEFILECACHE_H
#define POLSERVER_SOURCEFILECACHE_H
#include <map>
#include <memory>
#include <mutex>
#include <string>
namespace Pol::Bscript::Compiler
{
class SourceFile;
class SourceFileIdentifier;
class Profile;
class Report;
class SourceFileCache
{
public:
explicit SourceFileCache( Profile& profile ) : keep( 0 ), profile( profile ) {}
void configure( unsigned keep );
std::shared_ptr<SourceFile> load( const SourceFileIdentifier&, Report& report );
void keep_some();
void clear();
private:
unsigned keep;
std::mutex mutex;
std::map<std::string, std::shared_ptr<SourceFile>> files;
std::map<std::string, unsigned> frequency;
Profile& profile;
};
} // namespace Pol::Bscript::Compiler
#endif // POLSERVER_SOURCEFILECACHE_H