std::list<int> some_list;
std::mutex some_mutex;
void add_2_list(int new_value) {
std::lock_guard<std::mutex> guard(some_mutex);
some_list.push_back(new_value);
}
bool list_contains(int value_2_find) {
std:std::lock_guard<std::mutex> guard(some_mutex);
return std::find(some_list.begin(), some_list.end(), value_2_find) != some_list.end();
}
使用mutex保护链表操作
Comments 0
Sign in to comment and like
← More postsThat’s all for now. Thanks for reading.
No comments yet.