| 7298 | } |
| 7299 | |
| 7300 | bool Worker::wakeUp() |
| 7301 | { |
| 7302 | MutexLockGuard reqQueGuard(request_que_mutex, FB_FUNCTION); |
| 7303 | |
| 7304 | #ifdef _DEBUG |
| 7305 | int cnt = 0; |
| 7306 | for (server_req_t* req = request_que; req; req = req->req_next) |
| 7307 | cnt++; |
| 7308 | fb_assert(cnt == ports_pending); |
| 7309 | |
| 7310 | cnt = 0; |
| 7311 | for (server_req_t* req = active_requests; req; req = req->req_next) |
| 7312 | cnt++; |
| 7313 | fb_assert(cnt == ports_active); |
| 7314 | #endif |
| 7315 | |
| 7316 | if (!ports_pending) |
| 7317 | return true; |
| 7318 | |
| 7319 | MutexLockGuard guard(m_mutex, FB_FUNCTION); |
| 7320 | |
| 7321 | if (m_idleWorkers) |
| 7322 | { |
| 7323 | Worker* idle = m_idleWorkers; |
| 7324 | idle->setState(true); |
| 7325 | idle->m_sem.release(); |
| 7326 | return true; |
| 7327 | } |
| 7328 | |
| 7329 | if (m_cntAll - m_cntGoing >= ports_active + ports_pending) |
| 7330 | return true; |
| 7331 | |
| 7332 | return (m_cntAll - m_cntGoing >= MAX_THREADS); |
| 7333 | } |
| 7334 | |
| 7335 | void Worker::wakeUpAll() |
| 7336 | { |