MCPcopy Create free account
hub / github.com/MonaSolutions/MonaServer / run

Method run

MonaCore/include/Mona/Decoder.h:118–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116 }
117
118 bool run(Exception& ex) {
119
120 // Just one!
121
122 _new = false;
123
124 PoolBuffer pBuffer(_pBuffer.poolBuffers);
125 {
126 std::lock_guard<std::mutex> lock(_inMutex);
127 ASSERT_RETURN(!_input.empty(),true)
128 pBuffer.swap(_input.front());
129 _input.pop_front();
130 _address = _inAddresses.front();
131 _inAddresses.pop_front();
132 }
133
134 // add general buffer in front
135 if (!_pBuffer.empty()) {
136 if (!pBuffer.empty())
137 _pBuffer->append(pBuffer.data(),pBuffer.size());
138 pBuffer.swap(_pBuffer);
139 _pBuffer.release();
140 }
141
142 UInt32 consumed(0);
143
144 while(consumed<pBuffer.size()) { // while everything is not consumed
145
146 if (consumed) {
147 // not execute the first loop!
148 if (_pLastOut) {
149 _pBuffer->resize(pBuffer.size()-consumed, false);
150 memcpy(_pBuffer->data(), pBuffer->data()+consumed, _pBuffer->size());
151 pBuffer->resize(consumed);
152 _pLastOut->pBuffer.swap(pBuffer);
153 pBuffer.swap(_pBuffer);
154 } else
155 pBuffer->clip(consumed);
156 }
157
158 Exception exc;
159 _pLastOut = NULL;
160 consumed = OnDecoding::raise<0xFFFFFFFF>(exc, pBuffer->data(),pBuffer->size());
161
162 if (exc)
163 ERROR(name, ", ", exc.error())
164
165 if (!consumed) {
166 _pBuffer.swap(pBuffer); // memorize the rest in general buffer
167 break;
168 }
169
170 if (_pLastOut && consumed >= pBuffer.size()) {
171 _pLastOut->pBuffer.swap(pBuffer);
172 break;
173 }
174
175 }

Callers

nothing calls this directly

Calls 9

frontMethod · 0.80
resizeMethod · 0.80
clipMethod · 0.80
errorMethod · 0.80
emptyMethod · 0.45
appendMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected