void copy_from_disk_queue_to_memory_queue(auto_drainer_t::lock_t keepalive) {
     try {
         while (!keepalive.get_drain_signal()->is_pulsed()) {
             if (disk_queue->empty()) {
                 if (items_in_queue != memory_queue.size()) {
                     // There is a push in progress, there's no good way to wait on it, so we'll start a new coroutine later
                     restart_copy_coro = true;
                 } else {
                     disk_queue.reset();
                 }
                 break;
             }
             T value;
             disk_queue->pop(&value);
             if (memory_queue.full()) {
                 guarantee(notify_when_room_in_memory_queue == NULL);
                 cond_t cond;
                 assignment_sentry_t<cond_t *> assignment_sentry(&notify_when_room_in_memory_queue, &cond);
                 wait_interruptible(&cond, keepalive.get_drain_signal());
             }
             memory_queue.push_back(value);
             available_control.set_available(true);
         }
     } catch (const interrupted_exc_t &) {
         /* ignore */
     }
 }
Пример #2
0
 void copy_from_disk_queue_to_memory_queue(auto_drainer_t::lock_t keepalive) {
     try {
         while (!keepalive.get_drain_signal()->is_pulsed()) {
             if (disk_queue->empty()) {
                 if (items_in_queue != memory_queue.size()) {
                     // There is a push in progress, there's no good way to wait on
                     // it, so we'll start a new coroutine later
                     restart_copy_coro = true;
                 } else {
                     disk_queue.reset();
                 }
                 break;
             }
             write_message_t wm;
             copying_viewer_t viewer(&wm);
             disk_queue->pop(&viewer);
             if (memory_queue_free_space <= 0) {
                 guarantee(notify_when_room_in_memory_queue == nullptr);
                 cond_t cond;
                 assignment_sentry_t<cond_t *> assignment_sentry(
                     &notify_when_room_in_memory_queue, &cond);
                 wait_interruptible(&cond, keepalive.get_drain_signal());
             }
             memory_queue_free_space -= wm.size();
             memory_queue.emplace_back(std::move(wm));
             available_control.set_available(true);
         }
     } catch (const interrupted_exc_t &) {
         /* ignore */
     }
 }