| 23 | |
| 24 | template<typename T> |
| 25 | T * ObjectQueue<T>::read() { |
| 26 | /* mutex lock */ |
| 27 | std::unique_lock<std::mutex> lock(m_mutex); |
| 28 | |
| 29 | /* wait for data */ |
| 30 | tellpChanged.wait(lock, [&] { |
| 31 | return |
| 32 | m_abort || |
| 33 | !m_queue.empty() || |
| 34 | (m_tellg >= m_fileSize); |
| 35 | }); |
| 36 | |
| 37 | /* get first entry */ |
| 38 | T * ohb = nullptr; |
| 39 | if (m_queue.empty()) |
| 40 | m_rdstate = std::ios_base::eofbit | std::ios_base::failbit; |
| 41 | else { |
| 42 | ohb = m_queue.front(); |
| 43 | m_queue.pop(); |
| 44 | |
| 45 | /* set state */ |
| 46 | m_rdstate = std::ios_base::goodbit; |
| 47 | |
| 48 | /* increase get count */ |
| 49 | m_tellg++; |
| 50 | } |
| 51 | |
| 52 | /* notify */ |
| 53 | tellgChanged.notify_all(); |
| 54 | |
| 55 | return ohb; |
| 56 | } |
| 57 | |
| 58 | template<typename T> |
| 59 | uint32_t ObjectQueue<T>::tellg() const { |