| 107 | const size_t index = findOperationIndex(operation); |
| 108 | if (index == InvalidOperationIndex) |
| 109 | { |
| 110 | return; |
| 111 | } |
| 112 | |
| 113 | readyMutex.lock(); |
| 114 | schedulerMemory.readyOperations[index] = 1; |
| 115 | readyCV.broadcast(); |
| 116 | readyMutex.unlock(); |
| 117 | } |
| 118 | |
| 119 | SC::Result SC::HttpClientOperationScheduler::pollReady(size_t& numPolled, uint32_t waitMilliseconds) |
| 120 | { |
| 121 | if (not initialized) |
| 122 | return Result::Error(HttpClientResultCategory, HttpClientError::SchedulerNotInitialized); |
| 123 | |
| 124 | numPolled = 0; |
| 125 | |
| 126 | readyMutex.lock(); |
| 127 | if (not hasReadyOperationLocked() and waitMilliseconds > 0 and hasRequestsInFlight()) |
| 128 | { |
| 129 | (void)readyCV.wait(readyMutex, waitMilliseconds); |
| 130 | } |
| 131 | readyMutex.unlock(); |
| 132 | |
| 133 | for (size_t idx = 0; idx < schedulerMemory.operations.sizeInElements(); ++idx) |
| 134 | { |
| 135 | bool shouldPoll = false; |
| 136 | readyMutex.lock(); |
| 137 | if (schedulerMemory.readyOperations[idx] != 0) |
| 138 | { |
| 139 | schedulerMemory.readyOperations[idx] = 0; |
| 140 | shouldPoll = true; |
| 141 | } |
| 142 | readyMutex.unlock(); |
| 143 | |