EntryTable needs a rewrite.

This commit is contained in:
Ben Vanik 2015-01-31 23:51:45 -08:00
parent dd6a1b8cd4
commit 3454d1bdf5
1 changed files with 4 additions and 1 deletions

View File

@ -39,6 +39,9 @@ Entry* EntryTable::Get(uint64_t address) {
}
Entry::Status EntryTable::GetOrCreate(uint64_t address, Entry** out_entry) {
// TODO(benvanik): replace with a map with wait-free for find.
// https://github.com/facebook/folly/blob/master/folly/AtomicHashMap.h
lock_.lock();
const auto& it = map_.find(address);
Entry* entry = it != map_.end() ? it->second : nullptr;
@ -50,7 +53,7 @@ Entry::Status EntryTable::GetOrCreate(uint64_t address, Entry** out_entry) {
do {
lock_.unlock();
// TODO(benvanik): sleep for less time?
poly::threading::Sleep(std::chrono::microseconds(100));
poly::threading::Sleep(std::chrono::microseconds(10));
lock_.lock();
} while (entry->status == Entry::STATUS_COMPILING);
}