Get data and remove it from the buffer. */
| 38 | |
| 39 | /** Get data and remove it from the buffer. */ |
| 40 | std::pair<T, size_t> pop() |
| 41 | { |
| 42 | // block when pipe is empty and m_open, or in use. |
| 43 | m_sem_out.wait(); |
| 44 | pthread_mutex_lock(&m_mutex_queue); |
| 45 | |
| 46 | std::pair<T, size_t> temp = remove(); |
| 47 | |
| 48 | pthread_mutex_unlock(&m_mutex_queue); |
| 49 | |
| 50 | // If pipe is m_open ensure poping will allow one more push. |
| 51 | // Otherwise, let next accessor know pipe is closed. |
| 52 | if (temp.second) |
| 53 | m_sem_in.post(); |
| 54 | else { |
| 55 | assert(!m_open); |
| 56 | m_sem_out.post(); |
| 57 | } |
| 58 | return temp; |
| 59 | } |
| 60 | |
| 61 | /** Allows a pop when the pipe is empty to signal the pipe is |
| 62 | * closed. */ |
no test coverage detected