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