MCPcopy Create free account
hub / github.com/VirtualGL/virtualgl / run

Method run

server/VGLTrans.cpp:153–250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151
152
153void VGLTrans::run(void)
154{
155 Frame *lastf = NULL, *f = NULL;
156 long bytes = 0;
157 Timer timer, sleepTimer; double err = 0.; bool first = true;
158 int i;
159
160 try
161 {
162 VGLTrans::Compressor *comp[MAXPROCS]; Thread *cthread[MAXPROCS];
163 if(fconfig.verbose)
164 vglout.println("[VGL] Using %d compression threads on %d CPU cores",
165 nprocs, NumProcs());
166 for(i = 0; i < nprocs; i++)
167 comp[i] = new VGLTrans::Compressor(i, this);
168 if(nprocs > 1) for(i = 1; i < nprocs; i++)
169 {
170 cthread[i] = new Thread(comp[i]);
171 cthread[i]->start();
172 }
173
174 while(!deadYet)
175 {
176 int np;
177 void *ftemp = NULL;
178
179 q.get(&ftemp); f = (Frame *)ftemp; if(deadYet) break;
180 if(!f) THROW("Queue has been shut down");
181 ready.signal();
182 np = nprocs; if(f->hdr.compress == RRCOMP_YUV) np = 1;
183 if(np > 1)
184 {
185 for(i = 1; i < np; i++)
186 {
187 cthread[i]->checkError(); comp[i]->go(f, lastf);
188 }
189 }
190 comp[0]->compressSend(f, lastf);
191 bytes += comp[0]->bytes;
192 if(np > 1)
193 {
194 for(i = 1; i < np; i++)
195 {
196 comp[i]->stop(); cthread[i]->checkError(); comp[i]->send();
197 bytes += comp[i]->bytes;
198 }
199 }
200 sendHeader(f->hdr, true);
201
202 profTotal.endFrame(f->hdr.width * f->hdr.height, bytes, 1);
203 bytes = 0;
204 profTotal.startFrame();
205
206 if(fconfig.flushdelay > 0.)
207 {
208 long usec = (long)(fconfig.flushdelay * 1000000.);
209 if(usec > 0) usleep(usec);
210 }

Callers

nothing calls this directly

Calls 15

NumProcsFunction · 0.85
printlnMethod · 0.80
signalMethod · 0.80
checkErrorMethod · 0.80
goMethod · 0.80
compressSendMethod · 0.80
endFrameMethod · 0.80
startFrameMethod · 0.80
elapsedMethod · 0.80
signalCompleteMethod · 0.80
setErrorMethod · 0.80
startMethod · 0.45

Tested by

no test coverage detected