| 14 | #endif |
| 15 | |
| 16 | void ATA::IO_Thread() |
| 17 | { |
| 18 | std::unique_lock ioWaitHandle(ioMutex); |
| 19 | ioThreadIdle_bool = false; |
| 20 | ioWaitHandle.unlock(); |
| 21 | |
| 22 | while (true) |
| 23 | { |
| 24 | ioWaitHandle.lock(); |
| 25 | ioThreadIdle_bool = true; |
| 26 | ioThreadIdle_cv.notify_all(); |
| 27 | |
| 28 | ioReady.wait(ioWaitHandle, [&] { return ioRead | ioWrite; }); |
| 29 | ioThreadIdle_bool = false; |
| 30 | |
| 31 | int ioType = -1; |
| 32 | if (ioRead) |
| 33 | ioType = 0; |
| 34 | else if (ioWrite) |
| 35 | ioType = 1; |
| 36 | |
| 37 | ioWaitHandle.unlock(); |
| 38 | |
| 39 | //Read or Write |
| 40 | if (ioType == 0) |
| 41 | IO_Read(); |
| 42 | else if (ioType == 1) |
| 43 | { |
| 44 | if (!IO_Write()) |
| 45 | { |
| 46 | if (ioClose.load()) |
| 47 | { |
| 48 | ioClose.store(false); |
| 49 | ioWaitHandle.lock(); |
| 50 | ioThreadIdle_bool = true; |
| 51 | ioWaitHandle.unlock(); |
| 52 | return; |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | void ATA::IO_Read() |
| 60 | { |
nothing calls this directly
no test coverage detected