LCOV - code coverage report
Current view: top level - source/extensions/common/async_files - async_file_action.cc (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 0 10 0.0 %
Date: 2024-01-05 06:35:25 Functions: 0 1 0.0 %

          Line data    Source code
       1             : #include "source/extensions/common/async_files/async_file_action.h"
       2             : 
       3             : #include <thread>
       4             : 
       5             : namespace Envoy {
       6             : namespace Extensions {
       7             : namespace Common {
       8             : namespace AsyncFiles {
       9             : 
      10           0 : void AsyncFileAction::cancel() {
      11           0 :   auto previousState = state_.exchange(State::Cancelled);
      12           0 :   if (previousState == State::InCallback) {
      13             :     // A gentle spin-lock. This situation should be rare, and callbacks are
      14             :     // supposed to be quick, so we don't need a real lock here.
      15           0 :     while (state_.load() != State::Done) {
      16           0 :       std::this_thread::yield();
      17           0 :     }
      18           0 :   } else if (previousState == State::Done) {
      19           0 :     state_.store(State::Done);
      20           0 :   }
      21           0 : }
      22             : 
      23             : } // namespace AsyncFiles
      24             : } // namespace Common
      25             : } // namespace Extensions
      26             : } // namespace Envoy

Generated by: LCOV version 1.15