Skip to content

Use std::once_flag and std::call_once for time constant warnings. - #550

Merged
nkoukpaizan merged 3 commits into
developfrom
nicholson/unique-time-constant-warnings
Aug 26, 2026
Merged

Use std::once_flag and std::call_once for time constant warnings.#550
nkoukpaizan merged 3 commits into
developfrom
nicholson/unique-time-constant-warnings

Conversation

@nkoukpaizan

Copy link
Copy Markdown
Collaborator

Description

This uses std:once_flag and std::call_once to only warn user about the raised time constants once.
This removes the excessive warnings for this known issue.

Proposed changes

  • Added static void logTimeConstantWarning() to the relevant header files after TIME_CONSTANT_MINIMUM
  • Moved Log::Warning() call to the static method
  • Introduced std:once_flag and std::call_once at the call site, when the warning is warranted.

Checklist

  • [x ] All tests pass.
  • Code compiles cleanly with flags -Wall -Wpedantic -Wconversion -Wextra.
  • The new code follows GridKit™ style guidelines.
  • There are unit tests for the new code.
  • The new code is documented.
  • The feature branch is rebased with respect to the target branch.
  • [N/A] The CHANGELOG.md has been updated to reflect the changes. If this is a minor PR that is part of a larger fix already included in the file, state so.

Further comments

Will need to better generalize if a similar pattern is needed later.

@nkoukpaizan nkoukpaizan added this to the Release 0.2 milestone Aug 25, 2026
@nkoukpaizan nkoukpaizan self-assigned this Aug 25, 2026
@nkoukpaizan nkoukpaizan added the enhancement New feature or request label Aug 25, 2026

@lukelowry lukelowry left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I would have struggled with this.

If I run this on two different cases, will it error on the second case if it raises the same warnings?

@nkoukpaizan

Copy link
Copy Markdown
Collaborator Author

If I run this on two different cases, will it error on the second case if it raises the same warnings?

I don't see a scenario where we'd get an error, and I am not sure I understand the use-case you're describing, so let try these:

  • This is thread-safe for contingency analysis, so we get one warning for all contingencies.
  • If you have two separate executions of DynamicSimulation, you'll get a warning per executable.

@lukelowry

Copy link
Copy Markdown
Collaborator

If I run this on two different cases, will it error on the second case if it raises the same warnings?

I don't see a scenario where we'd get an error, and I am not sure I understand the use-case you're describing, so let try these:

  • This is thread-safe for contingency analysis, so we get one warning for all contingencies.

  • If you have two separate executions of DynamicSimulation, you'll get a warning per executable.

Okay that resolves my concern. Thank you sir

@superwhiskers superwhiskers left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks fine to me

@nkoukpaizan
nkoukpaizan force-pushed the nicholson/unique-time-constant-warnings branch from d847882 to 514df62 Compare August 26, 2026 21:03
@nkoukpaizan
nkoukpaizan merged commit 6c1a9aa into develop Aug 26, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants