EntryTable needs a rewrite.
This commit is contained in:
parent
dd6a1b8cd4
commit
3454d1bdf5
|
@ -39,6 +39,9 @@ Entry* EntryTable::Get(uint64_t address) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Entry::Status EntryTable::GetOrCreate(uint64_t address, Entry** out_entry) {
|
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();
|
lock_.lock();
|
||||||
const auto& it = map_.find(address);
|
const auto& it = map_.find(address);
|
||||||
Entry* entry = it != map_.end() ? it->second : nullptr;
|
Entry* entry = it != map_.end() ? it->second : nullptr;
|
||||||
|
@ -50,7 +53,7 @@ Entry::Status EntryTable::GetOrCreate(uint64_t address, Entry** out_entry) {
|
||||||
do {
|
do {
|
||||||
lock_.unlock();
|
lock_.unlock();
|
||||||
// TODO(benvanik): sleep for less time?
|
// TODO(benvanik): sleep for less time?
|
||||||
poly::threading::Sleep(std::chrono::microseconds(100));
|
poly::threading::Sleep(std::chrono::microseconds(10));
|
||||||
lock_.lock();
|
lock_.lock();
|
||||||
} while (entry->status == Entry::STATUS_COMPILING);
|
} while (entry->status == Entry::STATUS_COMPILING);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue