Path: utzoo!attcan!uunet!snorkelwacker!apple!mips!sgi!shinobu!odin!andru From: andru@sgi.com (Andrew Myers) Newsgroups: comp.sys.sgi Subject: Re: Problems with Event Queue Keywords: qtest v. qread, push operation Message-ID: <8888@odin.corp.sgi.com> Date: 13 Jun 90 17:20:53 GMT References: <14653@thorin.cs.unc.edu> Sender: news@odin.corp.sgi.com Organization: Silicon Graphics, Inc., Mountain View, CA Lines: 45 In article <14653@thorin.cs.unc.edu> surles@robinett.cs.unc.edu (Mark Surles) writes: >Is there any way to get both the event type and the value >without dequeueing the event? Or, can I read the event and then >somehow put it back at the FRONT of the queue? >Mark Surles >surles@cs.unc.edu You could implement a wrapper around qtest/qread, whose implementation would depend on how deep a pushback you needed. If you only need one level, something like this should suffice: #include "gl.h" #include "assert.h" long q_dev; short q_data; int q_hasdata; long my_qtest() { if (q_hasdata) return q_dev; else return qtest(); } long my_qread(short *data) { if (q_hasdata) { *data = q_data; return q_dev; } else { return qread(data); } } void my_qunread(long dev, short data) { assert(!q_hasdata); /* one level pushback requirement */ assert(dev != 0); /* dev==0 wouldn't make sense */ q_dev = dev; q_data = data; } ----- Andrew