| 175 | } |
| 176 | |
| 177 | int FTPQueue::QueueLoop() { |
| 178 | QueueOperation * op = NULL; |
| 179 | |
| 180 | while(!m_stopping) { |
| 181 | |
| 182 | m_monitor->Enter(); |
| 183 | while (m_queue.empty() && !m_stopping) |
| 184 | m_monitor->Wait(ConditionQueueOps); |
| 185 | |
| 186 | if (m_stopping) { |
| 187 | m_monitor->Exit(); |
| 188 | break; |
| 189 | } |
| 190 | |
| 191 | op = m_queue.front(); |
| 192 | m_activeOp = op; |
| 193 | m_performing = true; |
| 194 | m_monitor->Exit(); |
| 195 | |
| 196 | op->SendNotification(QueueOperation::QueueEventStart); |
| 197 | op->SetRunning(true); |
| 198 | Sleep(500); |
| 199 | op->Perform(); |
| 200 | op->SetRunning(false); |
| 201 | op->SendNotification(QueueOperation::QueueEventEnd); |
| 202 | |
| 203 | if (m_stopping) |
| 204 | break; |
| 205 | |
| 206 | op->SendNotification(QueueOperation::QueueEventRemove); |
| 207 | |
| 208 | m_monitor->Enter(); |
| 209 | m_activeOp = NULL; |
| 210 | m_performing = false; |
| 211 | m_queue.pop_front(); |
| 212 | delete op; |
| 213 | m_monitor->Exit(); |
| 214 | } |
| 215 | |
| 216 | m_monitor->Enter(); |
| 217 | m_performing = false; |
| 218 | m_monitor->Signal(ConditionQueueStop); |
| 219 | m_monitor->Exit(); |
| 220 | |
| 221 | return 0; |
| 222 | } |
| 223 | |
| 224 | int FTPQueue::OnDataReceived(long received, long total) { |
| 225 | m_monitor->Enter(); |
no test coverage detected