Rename variables to conform to LLVM naming conventions.

llvm-svn: 302697
This commit is contained in:
Zachary Turner 2017-05-10 17:39:18 +00:00
parent c47f039efd
commit 0a340ce3bc
2 changed files with 19 additions and 19 deletions

View File

@ -25,40 +25,40 @@ namespace lld {
///
/// Calling dec() on a Latch with a count of 0 has undefined behaivor.
class Latch {
uint32_t _count;
mutable std::mutex _condMut;
mutable std::condition_variable _cond;
uint32_t Count;
mutable std::mutex Mutex;
mutable std::condition_variable Cond;
public:
explicit Latch(uint32_t count = 0) : _count(count) {}
explicit Latch(uint32_t count = 0) : Count(count) {}
~Latch() { sync(); }
void inc() {
std::unique_lock<std::mutex> lock(_condMut);
++_count;
std::unique_lock<std::mutex> lock(Mutex);
++Count;
}
void dec() {
std::unique_lock<std::mutex> lock(_condMut);
if (--_count == 0)
_cond.notify_all();
std::unique_lock<std::mutex> lock(Mutex);
if (--Count == 0)
Cond.notify_all();
}
void sync() const {
std::unique_lock<std::mutex> lock(_condMut);
_cond.wait(lock, [&] { return _count == 0; });
std::unique_lock<std::mutex> lock(Mutex);
Cond.wait(lock, [&] { return Count == 0; });
}
};
/// \brief Allows launching a number of tasks and waiting for them to finish
/// either explicitly via sync() or implicitly on destruction.
class TaskGroup {
Latch _latch;
Latch L;
public:
void spawn(std::function<void()> f);
void spawn(std::function<void()> F);
void sync() const { _latch.sync(); }
void sync() const { L.sync(); }
};
}

View File

@ -132,10 +132,10 @@ Executor *Executor::getDefaultExecutor() {
#endif
}
void TaskGroup::spawn(std::function<void()> f) {
_latch.inc();
Executor::getDefaultExecutor()->add([&, f] {
f();
_latch.dec();
void TaskGroup::spawn(std::function<void()> F) {
L.inc();
Executor::getDefaultExecutor()->add([&, F] {
F();
L.dec();
});
}