()
| 217 | } |
| 218 | |
| 219 | private void triggerDiskUpdate() { |
| 220 | lastWriteTime = System.currentTimeMillis(); |
| 221 | if (writerThread == null || !writerThread.isAlive()) { |
| 222 | writerThread = new Thread(() -> { |
| 223 | long diff; |
| 224 | // Wait until there have been no virtual writes for specified delay time |
| 225 | while ((diff = System.currentTimeMillis() - lastWriteTime) < WRITE_UPDATE_DELAY) { |
| 226 | // Sleep for difference of time |
| 227 | LockSupport.parkNanos(diff * 1000); |
| 228 | // Note: In the meantime, there could have been another disk write, |
| 229 | // in which case this loop will repeat again as needed. |
| 230 | } |
| 231 | updateDisk(); |
| 232 | }); |
| 233 | writerThread.start(); |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | void insertDisk(File diskPath) throws IOException { |
| 238 | if (DEBUG) { |
no test coverage detected