| 167 | } |
| 168 | |
| 169 | void startWriter(const std::string & filepath) |
| 170 | { |
| 171 | g_stop = false; |
| 172 | g_persisted = false; |
| 173 | |
| 174 | std_boost::thread writer([filepath]() |
| 175 | { |
| 176 | const auto key = g_buffer.addTail(); |
| 177 | std::ofstream logfile; |
| 178 | logfile.open (filepath, std::ios::out); |
| 179 | |
| 180 | while (!g_stop || (g_buffer.size(key) != 0)) |
| 181 | { |
| 182 | auto i = g_buffer.cbegin(key); |
| 183 | |
| 184 | while (g_buffer.valid(key, i)) |
| 185 | { |
| 186 | logfile << *i; |
| 187 | i = g_buffer.next(key, i); |
| 188 | } |
| 189 | |
| 190 | logfile.flush(); |
| 191 | |
| 192 | std_boost::this_thread::sleep_for(std_boost::chrono::milliseconds(1)); |
| 193 | } |
| 194 | |
| 195 | logfile.close(); |
| 196 | g_buffer.removeTail(key); |
| 197 | g_persisted = true; |
| 198 | g_finishcheck.notify_all(); |
| 199 | }); |
| 200 | |
| 201 | writer.detach(); |
| 202 | } |
| 203 | |
| 204 | const std::string getStandardFilepath() |
| 205 | { |
no test coverage detected