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

Class Decompressor

common/frameut.cpp:216–301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

214
215
216class Decompressor : public Runnable
217{
218 public:
219
220 Decompressor(Blitter *blitter_, Display *dpy_, Window win_, int myID_) :
221 blitter(blitter_), findex(0), deadYet(false), dpy(dpy_), win(win_),
222 myID(myID_), thread(NULL)
223 {
224 thread = new Thread(this);
225 thread->start();
226 #ifdef USEHELGRIND
227 ANNOTATE_BENIGN_RACE_SIZED(&deadYet, sizeof(bool), );
228 #endif
229 }
230
231 virtual ~Decompressor(void) { shutdown(); }
232
233 CompressedFrame &get(void)
234 {
235 CompressedFrame &cframe = cframes[findex];
236 findex = (findex + 1) % NFRAMES;
237 if(deadYet) return cframe;
238 if(thread) thread->checkError();
239 if(!deadYet) cframe.waitUntilComplete();
240 if(thread) thread->checkError();
241 return cframe;
242 }
243
244 void put(CompressedFrame &cframe)
245 {
246 if(thread) thread->checkError();
247 cframe.signalReady();
248 }
249
250 void shutdown(void)
251 {
252 deadYet = true;
253 int i;
254 for(i = 0; i < NFRAMES; i++)
255 cframes[i].signalReady(); // Release my thread
256 if(thread)
257 {
258 thread->stop(); delete thread; thread = NULL;
259 }
260 for(i = 0; i < NFRAMES; i++)
261 cframes[i].signalComplete(); // Release compressor
262 }
263
264 private:
265
266 void run(void)
267 {
268 int index = 0; Frame *frame = NULL;
269 try
270 {
271 while(!deadYet)
272 {
273 CompressedFrame &cframe = cframes[index];

Callers

nothing calls this directly

Calls 2

checkErrorMethod · 0.80
waitUntilCompleteMethod · 0.80

Tested by

no test coverage detected