The "mainline" executed by the worker thread.
| 107 | |
| 108 | /// The "mainline" executed by the worker thread. |
| 109 | virtual int svc() { |
| 110 | DBG_ENTRY("QueueTaskBase","svc"); |
| 111 | |
| 112 | ThreadStatusManager& thread_status_manager = TheServiceParticipant->get_thread_status_manager(); |
| 113 | |
| 114 | ThreadStatusManager::Start s(thread_status_manager, "QueueTaskBase"); |
| 115 | |
| 116 | thr_id_ = ACE_OS::thr_self(); |
| 117 | |
| 118 | // Start the "GetWork-And-PerformWork" loop for the current worker thread. |
| 119 | while (!this->shutdown_initiated_) { |
| 120 | T req; |
| 121 | { |
| 122 | GuardType guard(this->lock_); |
| 123 | |
| 124 | if (this->queue_.is_empty() && !shutdown_initiated_) { |
| 125 | const TimeDuration thread_status_interval = thread_status_manager.thread_status_interval(); |
| 126 | if (thread_status_interval) { |
| 127 | MonotonicTimePoint expire = MonotonicTimePoint::now() + thread_status_interval; |
| 128 | |
| 129 | do { |
| 130 | work_available_.wait_until(expire, thread_status_manager); |
| 131 | |
| 132 | MonotonicTimePoint now = MonotonicTimePoint::now(); |
| 133 | if (now > expire) { |
| 134 | expire = now + thread_status_interval; |
| 135 | } |
| 136 | } while (this->queue_.is_empty() && !shutdown_initiated_); |
| 137 | } else { |
| 138 | this->work_available_.wait(thread_status_manager); |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | if (this->shutdown_initiated_) |
| 143 | break; |
| 144 | |
| 145 | int result = queue_.dequeue_head(req); |
| 146 | |
| 147 | if (result != 0) { |
| 148 | //I'm not sure why this thread got more signals than actual signals |
| 149 | //when using thread_per_connection and the user application thread |
| 150 | //send requests without interval. We just need ignore the dequeue |
| 151 | //failure. |
| 152 | //ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: QueueTaskBase::svc %p\n", |
| 153 | // ACE_TEXT("dequeue_head"))); |
| 154 | continue; |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | this->execute(req); |
| 159 | } |
| 160 | |
| 161 | // This will never get executed. |
| 162 | return 0; |
| 163 | } |
| 164 | |
| 165 | /// Called when the thread exits. |
| 166 | virtual int close(u_long flag = 0) { |
nothing calls this directly
no test coverage detected