LRU work to load functions off of the main thread.

We'll have to reevaluate this after we fix function autocomplete
This commit is contained in:
ridiculousfish
2012-01-28 14:56:13 -08:00
parent 87429bc03c
commit 4eea68b5a4
7 changed files with 201 additions and 93 deletions

View File

@@ -79,6 +79,9 @@ class lru_cache_impl_t {
/** Adds a node under the given key. Returns true if the node was added, false if the node was not because a node with that key is already in the set. */
bool add_node(lru_node_t *node);
/** Adds a node under the given key without triggering eviction. Returns true if the node was added, false if the node was not because a node with that key is already in the set. */
bool add_node_without_eviction(lru_node_t *node);
/** Counts nodes */
size_t size(void) { return node_count; }
@@ -105,6 +108,7 @@ struct autoload_function_t : public lru_node_t
struct builtin_script_t;
class env_vars;
/**
A class that represents a path from which we can autoload, and the autoloaded contents.
@@ -112,6 +116,9 @@ struct builtin_script_t;
class autoload_t : private lru_cache_t<autoload_function_t> {
private:
/** Lock for thread safety */
pthread_mutex_t lock;
/** The environment variable name */
const wcstring env_var_name;
@@ -138,6 +145,8 @@ class autoload_t : private lru_cache_t<autoload_function_t> {
this->evict_all_nodes();
}
bool file_already_autoloaded(const wcstring &cmd, bool require_loaded, bool allow_stale_functions);
bool locate_file_and_maybe_load_it( const wcstring &cmd, bool really_load, bool reload, const wcstring_list_t &path_list );
virtual void node_was_evicted(autoload_function_t *node);
@@ -152,6 +161,9 @@ class autoload_t : private lru_cache_t<autoload_function_t> {
/** Create an autoload_t for the given environment variable name */
autoload_t(const wcstring &env_var_name_var, const builtin_script_t *scripts, size_t script_count );
/** Destructor */
virtual ~autoload_t();
/**
Autoload the specified file, if it exists in the specified path. Do
not load it multiple times unless it's timestamp changes or
@@ -181,7 +193,7 @@ class autoload_t : private lru_cache_t<autoload_function_t> {
void unload_all( );
/** Check whether the given command could be loaded, but do not load it. */
bool can_load( const wcstring &cmd );
bool can_load( const wcstring &cmd, const env_vars &vars );
};