Forums > Dev

qelems and while loops

July 21, 2007 | 10:26 pm

Hello,

Does it defeat the entire purpose of a qelem to include a while loop
in it?

I’m reading data from a buffer…something like:

while (datainbuffer) {
read some;
}

Should I be doing something like:

if (datainbuffer) {
read some;
}
qelem_set(*qe);

Thanks…

b

Barry Threw
Media Art and Technology

San Francisco, CA Work: 857-544-3967
Email: bthrew@gmail.com
IM: captogreadmore (AIM)
http:/www.barrythrew.com


July 24, 2007 | 10:17 am

Depends on what your purpose is in using the qelem. Typically, you
use it to either make sure that something happens in the low-priority
thread, or to break up a longer process into bite-sized chunks. In
any case, the two functions that you show aren’t really that
different, except that the while() version could spin longer
(potentially indefinitely). If datainbuffer will always be false
after a read, they are functionally identical.

while(1) ; in a qelem will hang Max, just as while(1) ; in new() or
free() would.

jb

Am 22.07.2007 um 00:26 schrieb barry threw:

> Hello,
>
> Does it defeat the entire purpose of a qelem to include a while
> loop in it?
>
> I’m reading data from a buffer…something like:
>
> while (datainbuffer) {
> read some;
> }
>
> Should I be doing something like:
>
> if (datainbuffer) {
> read some;
> }
> qelem_set(*qe);
>
> Thanks…
>
> b
>
> Barry Threw
> Media Art and Technology
>
>
> San Francisco, CA Work: 857-544-3967
> Email: bthrew@gmail.com
> IM: captogreadmore (AIM)
> http:/www.barrythrew.com
>
>
>


Viewing 2 posts - 1 through 2 (of 2 total)