Skip to content

Commit

Permalink
styles: 不显示指定锁的模板类型
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Dec 4, 2024
1 parent 368f33f commit 4f567eb
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
10 changes: 5 additions & 5 deletions source/MaaAdbControlUnit/Screencap/Minicap/MinicapStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ std::optional<cv::Mat> MinicapStream::screencap()
{
LogDebug;

std::unique_lock<std::mutex> locker(mutex_);
std::unique_lock locker(mutex_);

using namespace std::chrono_literals;
cond_.wait_for(locker, 2s); // 等下一帧
Expand Down Expand Up @@ -163,7 +163,7 @@ void MinicapStream::pulling()
auto size_opt = read(4);
if (!size_opt) {
LogError << "read size failed";
std::unique_lock<std::mutex> locker(mutex_);
std::unique_lock locker(mutex_);
image_ = cv::Mat();
continue;
}
Expand All @@ -172,7 +172,7 @@ void MinicapStream::pulling()
auto data_opt = read(size);
if (!data_opt) {
LogError << "read data failed";
std::unique_lock<std::mutex> locker(mutex_);
std::unique_lock locker(mutex_);
image_ = cv::Mat();
continue;
}
Expand All @@ -181,12 +181,12 @@ void MinicapStream::pulling()

if (!img_opt || img_opt->empty()) {
LogError << "decode jpg failed";
std::unique_lock<std::mutex> locker(mutex_);
std::unique_lock locker(mutex_);
image_ = cv::Mat();
continue;
}

std::unique_lock<std::mutex> locker(mutex_);
std::unique_lock locker(mutex_);
image_ = std::move(*img_opt);
cond_.notify_all();
}
Expand Down
26 changes: 13 additions & 13 deletions source/MaaFramework/Base/AsyncRunner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ inline void AsyncRunner<Item>::release()
exit_ = true;

{
std::unique_lock<std::mutex> queue_lock(queue_mutex_);
std::unique_lock queue_lock(queue_mutex_);
queue_cond_.notify_all();
}

{
std::unique_lock<std::mutex> compl_lock(compl_mutex_);
std::unique_lock compl_lock(compl_mutex_);
compl_cond_.notify_all();
}

Expand All @@ -102,7 +102,7 @@ inline void AsyncRunner<Item>::working()
// LogFunc;

while (!exit_) {
std::unique_lock<std::mutex> queue_lock(queue_mutex_);
std::unique_lock queue_lock(queue_mutex_);

if (queue_.empty()) {
running_ = false;
Expand All @@ -117,7 +117,7 @@ inline void AsyncRunner<Item>::working()
queue_.pop_front();
queue_lock.unlock();

std::unique_lock<std::shared_mutex> status_lock(status_mutex_);
std::unique_lock status_lock(status_mutex_);
status_map_[id] = MaaStatus_Running;
status_lock.unlock();

Expand All @@ -127,7 +127,7 @@ inline void AsyncRunner<Item>::working()
status_map_[id] = ret ? MaaStatus_Succeeded : MaaStatus_Failed;
status_lock.unlock();

std::unique_lock<std::mutex> compl_lock(compl_mutex_);
std::unique_lock compl_lock(compl_mutex_);
compl_id_ = id;
compl_cond_.notify_all();
}
Expand All @@ -140,12 +140,12 @@ inline typename AsyncRunner<Item>::Id AsyncRunner<Item>::post(Item item, bool bl

Id id = MaaInvalidId;
{
std::unique_lock<std::mutex> queue_lock(queue_mutex_);
std::unique_lock queue_lock(queue_mutex_);
id = ++cross_inst_id_;
queue_.emplace_back(id, std::move(item));

{
std::unique_lock<std::shared_mutex> status_lock(status_mutex_);
std::unique_lock status_lock(status_mutex_);
status_map_.emplace(id, MaaStatus_Pending);
}

Expand All @@ -166,7 +166,7 @@ inline void AsyncRunner<Item>::wait(Id id) const
// LogFunc << VAR(id);

while (!exit_) {
std::unique_lock<std::mutex> compl_lock(compl_mutex_);
std::unique_lock compl_lock(compl_mutex_);
if (id <= compl_id_) {
return;
}
Expand All @@ -181,7 +181,7 @@ inline void AsyncRunner<Item>::wait_all() const
LogFunc;

while (!exit_) {
std::unique_lock<std::mutex> compl_lock(compl_mutex_);
std::unique_lock compl_lock(compl_mutex_);
if (!running_) {
return;
}
Expand All @@ -193,7 +193,7 @@ inline void AsyncRunner<Item>::wait_all() const
template <typename Item>
inline MaaStatus AsyncRunner<Item>::status(Id id) const
{
std::shared_lock<std::shared_mutex> status_lock(status_mutex_);
std::shared_lock status_lock(status_mutex_);

auto iter = status_map_.find(id);
if (iter == status_map_.end()) {
Expand All @@ -208,19 +208,19 @@ inline void AsyncRunner<Item>::clear()
// LogFunc;

{
std::unique_lock<std::mutex> queue_lock(queue_mutex_);
std::unique_lock queue_lock(queue_mutex_);
queue_ = {};
queue_cond_.notify_all();
}

{
std::unique_lock<std::mutex> compl_lock(compl_mutex_);
std::unique_lock compl_lock(compl_mutex_);
compl_id_ = cross_inst_id_;
compl_cond_.notify_all();
}

{
std::unique_lock<std::shared_mutex> status_lock(status_mutex_);
std::unique_lock status_lock(status_mutex_);
status_map_.clear();
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/MaaFramework/Controller/ControllerAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ bool ControllerAgent::input_text(const std::string& text)

cv::Mat ControllerAgent::screencap()
{
std::unique_lock<std::mutex> lock(image_mutex_);
std::unique_lock lock(image_mutex_);
auto id = post_screencap_impl();
if (wait(id) != MaaStatus_Succeeded) {
return {};
Expand Down
6 changes: 3 additions & 3 deletions source/MaaUtils/Logger/Logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ bool Logger::rotate()
return false;
}

std::unique_lock<std::mutex> trace_lock(trace_mutex_);
std::unique_lock trace_lock(trace_mutex_);
if (ofs_.is_open()) {
ofs_.close();
}
Expand Down Expand Up @@ -157,7 +157,7 @@ void Logger::open()

std::filesystem::create_directories(log_dir_);

std::unique_lock<std::mutex> trace_lock(trace_mutex_);
std::unique_lock trace_lock(trace_mutex_);
if (ofs_.is_open()) {
ofs_.close();
}
Expand All @@ -183,7 +183,7 @@ void Logger::close()
internal_dbg() << "Close log";
internal_dbg() << kSplitLine;

std::unique_lock<std::mutex> trace_lock(trace_mutex_);
std::unique_lock trace_lock(trace_mutex_);
if (ofs_.is_open()) {
ofs_.close();
}
Expand Down
6 changes: 3 additions & 3 deletions source/include/LibraryHolder/LibraryHolder.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ inline bool LibraryHolder<T>::load_library(const std::filesystem::path& libname)
{
LogFunc << VAR(libname);

std::unique_lock<std::mutex> lock(mutex_);
std::unique_lock lock(mutex_);

if (module_.is_loaded()) {
if (libname_ != libname) {
Expand Down Expand Up @@ -87,7 +87,7 @@ inline void LibraryHolder<T>::unload_library()
{
LogFunc << VAR(libname_);

std::unique_lock<std::mutex> lock(mutex_);
std::unique_lock lock(mutex_);

if (!module_.is_loaded()) {
LogDebug << "LibraryHolder already unloaded";
Expand All @@ -114,7 +114,7 @@ inline boost::function<FuncT> LibraryHolder<T>::get_function(const std::string&
{
LogFunc << VAR(func_name);

std::unique_lock<std::mutex> lock(mutex_);
std::unique_lock lock(mutex_);

if (!module_.is_loaded()) {
LogError << "LibraryHolder not loaded";
Expand Down
2 changes: 1 addition & 1 deletion source/include/Utils/LoggerUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class MAA_UTILS_API LogStream

~LogStream()
{
std::unique_lock<std::mutex> lock(mutex_);
std::unique_lock lock(mutex_);

if (stdout_) {
std::cout << stdout_string() << std::endl;
Expand Down

0 comments on commit 4f567eb

Please sign in to comment.