| 420 | } |
| 421 | |
| 422 | bool setProgress( float p ) |
| 423 | { |
| 424 | auto& instance = ProgressBarImpl::instance(); |
| 425 | if ( p == instance.progress_ ) |
| 426 | return !instance.canceled_; // fast path if the progress value has not changed |
| 427 | |
| 428 | int newPercents = int( p * 100.0f ); |
| 429 | int percents = instance.percents_; |
| 430 | if ( percents != newPercents && instance.percents_.compare_exchange_strong( percents, newPercents ) ) |
| 431 | { |
| 432 | std::unique_lock lock( instance.mutex_ ); |
| 433 | spdlog::info( "Operation progress: \"{}\" - {}%", instance.title_, newPercents ); |
| 434 | } |
| 435 | |
| 436 | assert( p >= instance.progress_ ); // the progress must not jump backward |
| 437 | assert( p <= 1 ); // the progress must not exceed 100% |
| 438 | instance.progress_ = p; |
| 439 | instance.frameRequest_.requestFrame(); |
| 440 | return !instance.canceled_; |
| 441 | } |
| 442 | |
| 443 | void setTaskCount( int n ) |
| 444 | { |
no test coverage detected