MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / pollReady

Method pollReady

Libraries/HttpClient/HttpClientScheduler.cpp:109–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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
119SC::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

Callers 2

operationSchedulerMethod · 0.80
saneMainFunction · 0.80

Calls 5

pollMethod · 0.80
ResultClass · 0.50
lockMethod · 0.45
waitMethod · 0.45
unlockMethod · 0.45

Tested by 1

operationSchedulerMethod · 0.64