Skip to content

Commit

Permalink
add try_get_params
Browse files Browse the repository at this point in the history
  • Loading branch information
KentaKato committed Jun 13, 2024
1 parent 88e7f79 commit 88a4f64
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,17 @@ struct StackParams {
return params_;
}

bool try_get_params(Params & params_in) const{
if (mutex_.try_lock()) {
if (const bool is_old = params_in.__stamp != params_.__stamp; is_old) {
params_in = params_;
}
mutex_.unlock();
return true;
}
return false;
}

bool is_old(Params const& other) const {
std::lock_guard<std::mutex> lock(mutex_);
return params_.__stamp != other.__stamp;
Expand Down

0 comments on commit 88a4f64

Please sign in to comment.