Async version to continue collecting points in parallel, while writing a file.
| 170 | |
| 171 | // Async version to continue collecting points in parallel, while writing a file. |
| 172 | void FlushAsync() |
| 173 | { |
| 174 | if (m_future.valid()) |
| 175 | m_future.wait(); |
| 176 | |
| 177 | BufferT * pBuffer = new BufferT(std::move(m_buffer)); |
| 178 | m_buffer.clear(); |
| 179 | m_buffer.reserve(kBufferSize); |
| 180 | |
| 181 | // Using raw pointers because we can't make std::function with rvalue reference. |
| 182 | m_future = std::async(std::launch::async, [this, pBuffer]() |
| 183 | { |
| 184 | FlushImpl(*pBuffer); |
| 185 | delete pBuffer; |
| 186 | }); |
| 187 | } |
| 188 | |
| 189 | void Flush() |
| 190 | { |