| 36 | {} |
| 37 | |
| 38 | void ThreadStatusManager::Thread::update(const MonotonicTimePoint& m_now, |
| 39 | const SystemTimePoint& s_now, |
| 40 | ThreadStatus next_status, |
| 41 | const TimeDuration& bucket_limit, |
| 42 | bool nested, int detail1, int detail2) |
| 43 | { |
| 44 | timestamp_ = s_now; |
| 45 | |
| 46 | if (nested) { |
| 47 | (next_status == ThreadStatus_Active) ? ++nesting_depth_ : --nesting_depth_; |
| 48 | } |
| 49 | |
| 50 | if (!nested || |
| 51 | (next_status == ThreadStatus_Active && nesting_depth_ == 1) || |
| 52 | (next_status == ThreadStatus_Idle && nesting_depth_ == 0)) { |
| 53 | if (buckets_[current_bucket_].total_time() > bucket_limit) { |
| 54 | current_bucket_ = (current_bucket_ + 1) % BUCKET_COUNT; |
| 55 | Bucket& current = buckets_[current_bucket_]; |
| 56 | total_.active_time -= current.active_time; |
| 57 | current.active_time = 0; |
| 58 | total_.idle_time -= current.idle_time; |
| 59 | current.idle_time = 0; |
| 60 | } |
| 61 | |
| 62 | const TimeDuration t = m_now - last_update_; |
| 63 | |
| 64 | switch (status_) { |
| 65 | case ThreadStatus_Active: |
| 66 | buckets_[current_bucket_].active_time += t; |
| 67 | total_.active_time += t; |
| 68 | break; |
| 69 | case ThreadStatus_Idle: |
| 70 | buckets_[current_bucket_].idle_time += t; |
| 71 | total_.idle_time += t; |
| 72 | break; |
| 73 | } |
| 74 | |
| 75 | last_status_change_ = m_now; |
| 76 | status_ = next_status; |
| 77 | } |
| 78 | detail1_ = detail1; |
| 79 | detail2_ = detail2; |
| 80 | last_update_ = m_now; |
| 81 | } |
| 82 | |
| 83 | namespace { |
| 84 | TimeDuration bonus_time(const MonotonicTimePoint& now, const MonotonicTimePoint& last_change, |
no test coverage detected