mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Remove template types from lock RAII wrapper usages (#1756)
C++17 has template type autodeduction. These wrappers include std::lock_guard and std::unique_lock.
This commit is contained in:
committed by
Peter Johnson
parent
e582518bae
commit
841ef5d739
@@ -1,5 +1,5 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2018 FIRST. All Rights Reserved. */
|
||||
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
@@ -16,12 +16,12 @@ PromiseFactoryBase::~PromiseFactoryBase() {
|
||||
}
|
||||
|
||||
void PromiseFactoryBase::IgnoreResult(uint64_t request) {
|
||||
std::unique_lock<wpi::mutex> lock(m_resultMutex);
|
||||
std::unique_lock lock(m_resultMutex);
|
||||
EraseRequest(request);
|
||||
}
|
||||
|
||||
uint64_t PromiseFactoryBase::CreateRequest() {
|
||||
std::unique_lock<wpi::mutex> lock(m_resultMutex);
|
||||
std::unique_lock lock(m_resultMutex);
|
||||
uint64_t req = ++m_uid;
|
||||
m_requests.push_back(req);
|
||||
return req;
|
||||
@@ -39,14 +39,14 @@ bool PromiseFactoryBase::EraseRequest(uint64_t request) {
|
||||
} // namespace detail
|
||||
|
||||
future<void> PromiseFactory<void>::MakeReadyFuture() {
|
||||
std::unique_lock<wpi::mutex> lock(GetResultMutex());
|
||||
std::unique_lock lock(GetResultMutex());
|
||||
uint64_t req = CreateErasedRequest();
|
||||
m_results.emplace_back(req);
|
||||
return future<void>{this, req};
|
||||
}
|
||||
|
||||
void PromiseFactory<void>::SetValue(uint64_t request) {
|
||||
std::unique_lock<wpi::mutex> lock(GetResultMutex());
|
||||
std::unique_lock lock(GetResultMutex());
|
||||
if (!EraseRequest(request)) return;
|
||||
auto it = std::find_if(m_thens.begin(), m_thens.end(),
|
||||
[=](const auto& x) { return x.request == request; });
|
||||
@@ -63,7 +63,7 @@ void PromiseFactory<void>::SetValue(uint64_t request) {
|
||||
|
||||
void PromiseFactory<void>::SetThen(uint64_t request, uint64_t outRequest,
|
||||
ThenFunction func) {
|
||||
std::unique_lock<wpi::mutex> lock(GetResultMutex());
|
||||
std::unique_lock lock(GetResultMutex());
|
||||
auto it = std::find_if(m_results.begin(), m_results.end(),
|
||||
[=](const auto& r) { return r == request; });
|
||||
if (it != m_results.end()) {
|
||||
@@ -75,7 +75,7 @@ void PromiseFactory<void>::SetThen(uint64_t request, uint64_t outRequest,
|
||||
}
|
||||
|
||||
bool PromiseFactory<void>::IsReady(uint64_t request) noexcept {
|
||||
std::unique_lock<wpi::mutex> lock(GetResultMutex());
|
||||
std::unique_lock lock(GetResultMutex());
|
||||
auto it = std::find_if(m_results.begin(), m_results.end(),
|
||||
[=](const auto& r) { return r == request; });
|
||||
return it != m_results.end();
|
||||
@@ -83,7 +83,7 @@ bool PromiseFactory<void>::IsReady(uint64_t request) noexcept {
|
||||
|
||||
void PromiseFactory<void>::GetResult(uint64_t request) {
|
||||
// wait for response
|
||||
std::unique_lock<wpi::mutex> lock(GetResultMutex());
|
||||
std::unique_lock lock(GetResultMutex());
|
||||
while (IsActive()) {
|
||||
// Did we get a response to *our* request?
|
||||
auto it = std::find_if(m_results.begin(), m_results.end(),
|
||||
@@ -100,7 +100,7 @@ void PromiseFactory<void>::GetResult(uint64_t request) {
|
||||
|
||||
void PromiseFactory<void>::WaitResult(uint64_t request) {
|
||||
// wait for response
|
||||
std::unique_lock<wpi::mutex> lock(GetResultMutex());
|
||||
std::unique_lock lock(GetResultMutex());
|
||||
while (IsActive()) {
|
||||
// Did we get a response to *our* request?
|
||||
auto it = std::find_if(m_results.begin(), m_results.end(),
|
||||
|
||||
Reference in New Issue
Block a user