Make bundle item queries thread safe

Note though that mutating the bundle item index is not allowed if other threads are querying it.
This commit is contained in:
Allan Odgaard
2013-07-25 15:58:37 +02:00
parent b9a06b3e0a
commit ce395fa46a
3 changed files with 13 additions and 0 deletions

View File

@@ -237,6 +237,9 @@ namespace parse
grammar_ptr parse_grammar (bundles::item_ptr const& grammarItem)
{
static std::recursive_mutex Mutex;
std::lock_guard<std::recursive_mutex> lock(Mutex);
static std::map<oak::uuid_t, grammar_ptr> Cache;
injected_grammars(); // ensure these are loaded in the main thread