Skip to content

Rework batch processor to elaborate in code comments / avoid while(...) loops #477

Description

@maxgolov

There's a code in Batch Log processor that contains the following constructs:

  while (is_force_flush_.load() == true)
  {
    cv_.notify_one();
  }

These constructs look suspicious, as "what if" the other thread does not refresh the is_force_flush value - does it mean that we are effectively busy-waiting, burning CPU cycles?

Should this be supplemented with some timed idle-wait or with std::thread::yield , or reworked using conditional variables?

Discussed with @open-telemetry/cpp-approvers during SIG call that the code as it is coded - looks funky, but should be fine .. Let's see if it can be reworked long-term to look cleaner.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions