| 54 | } |
| 55 | |
| 56 | int FTPQueue::Deinitialize() { |
| 57 | if (!m_running) |
| 58 | return 0; |
| 59 | |
| 60 | //Notifications sent from this function are handled immediatly, since they're from the local thread. |
| 61 | //Therefore, peekmessage won't remove any messages that this function sent, as they won;t be queued |
| 62 | |
| 63 | m_monitor->Enter(); |
| 64 | m_stopping = true; |
| 65 | |
| 66 | if (m_performing) { |
| 67 | m_queue.front()->Terminate(); |
| 68 | m_queue.front()->SendNotification(QueueOperation::QueueEventEnd); |
| 69 | //m_queue.front()->SendNotification(QueueOperation::QueueEventRemove); |
| 70 | } |
| 71 | |
| 72 | m_monitor->Signal(ConditionQueueOps); |
| 73 | m_monitor->Wait(ConditionQueueStop); |
| 74 | m_monitor->Exit(); |
| 75 | |
| 76 | while (!m_queue.empty()) { |
| 77 | //Remove any remaining messages (most notably Progress messages) |
| 78 | m_queue.front()->ClearPendingNotifications(); |
| 79 | m_queue.front()->SendNotification(QueueOperation::QueueEventRemove); |
| 80 | delete m_queue.front(); |
| 81 | m_queue.pop_front(); |
| 82 | } |
| 83 | |
| 84 | m_running = false; |
| 85 | m_stopping = false; |
| 86 | m_performing = false; |
| 87 | |
| 88 | return 0; |
| 89 | } |
| 90 | |
| 91 | int FTPQueue::AddQueueOp(QueueOperation * op) { |
| 92 | op->SetClient(m_wrapper); |
no test coverage detected