Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Non-Blocking try_get_params Function for Real-Time Control Systems #205

Merged
merged 3 commits into from
Jun 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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{
KentaKato marked this conversation as resolved.
Show resolved Hide resolved
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
Loading