feat(frontends/lean/server): add CLEAR_CACHE command, closes #100

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2014-08-27 10:31:01 -07:00
parent f4c7154825
commit fab4eb0d69
3 changed files with 10 additions and 0 deletions

View file

@ -97,6 +97,7 @@ static std::string g_info("INFO");
static std::string g_set("SET");
static std::string g_eval("EVAL");
static std::string g_wait("WAIT");
static std::string g_clear_cache("CLEAR_CACHE");
static bool is_command(std::string const & cmd, std::string const & line) {
return line.compare(0, cmd.size(), cmd) == 0;
@ -319,6 +320,8 @@ bool server::operator()(std::istream & in) {
} else if (is_command(g_eval, line)) {
read_line(in, line);
eval(line);
} else if (is_command(g_clear_cache, line)) {
m_cache.clear();
} else if (is_command(g_wait, line)) {
if (m_thread_ptr) {
m_thread_ptr->join();

View file

@ -150,6 +150,11 @@ void definition_cache::erase(name const & n) {
m_definitions.erase(n);
}
void definition_cache::clear() {
lock_guard<mutex> lc(m_mutex);
m_definitions.clear();
}
optional<std::tuple<level_param_names, expr, expr>> definition_cache::find(name const & n, expr const & pre_type, expr const & pre_value) {
entry const * it;
{

View file

@ -36,5 +36,7 @@ public:
void load(std::istream & in);
/** \brief Remove the entry named \c n from the cache. */
void erase(name const & n);
/** \brief Clear the whole cache */
void clear();
};
}