Is called from one other thread than main thread (by the manager socket thread, so here socket is necessary managed, and _sockfd is good)
| 419 | |
| 420 | // Is called from one other thread than main thread (by the manager socket thread, so here socket is necessary managed, and _sockfd is good) |
| 421 | bool flush(Exception& ex) { |
| 422 | ASSERT_RETURN(_initialized, false); |
| 423 | lock_guard<recursive_mutex> lock(_mutexManaged); |
| 424 | if (!_pManagedSocket) |
| 425 | return true; // mean no Senders queue!! |
| 426 | lock_guard<mutex> lockAsync(_mutexAsync); |
| 427 | while (!_senders.empty()) { |
| 428 | shared_ptr<SocketSender>& pSender(_senders.front()); |
| 429 | _mutexAsync.unlock(); |
| 430 | if (!pSender->flush(ex,*_pSocket)) { |
| 431 | _mutexAsync.lock(); |
| 432 | if (!_writing) |
| 433 | _writing = manager.startWrite(_sockfd,_pManagedSocket); |
| 434 | return false; |
| 435 | } |
| 436 | _mutexAsync.lock(); |
| 437 | _senders.pop_front(); |
| 438 | } |
| 439 | if (_writing) |
| 440 | _writing = !manager.stopWrite(_sockfd,_pManagedSocket); |
| 441 | return true; |
| 442 | } |
| 443 | |
| 444 | |
| 445 | bool managed(Exception& ex) { |