andrew@resam.dk (Leif Andrew Rump) (02/07/91)
I received three (3) answers to my original very interesting post. :-) YOU CAN DO BETTER - and I don't accept cheating like making the Reset button inactive or changing it to a Reset button, etc.!!! :-( Well instead of writing the whole thing one more time I'll ask only for some suggestions on how to prevent busy waiting if I have the following code (stolen from p.400 in Volume Seven of guess what!): XFlush(dpy); while (!reset_pressed) { notify_dispatch(); XFlush(dpy); /* Here is the problem - I don't have any code to put here! */ } The reason I don't have any code to put in is that I'm waiting (using notify_set_input_func & notify_set_itimer_func) for some input or the timer to time out and I'm using this piece of code because I want to stay in the callback routine to keep the button that activated the callback routine in busy state... Any suggestions? - Please! Leif Andrew Leif Andrew Rump, AmbraSoft A/S, Stroedamvej 50, DK-2100 Copenhagen OE, Denmark UUCP: andrew@ambra.dk, phone: +45 39 27 11 77 / Currently at Scandinavian Airline Systems =======/ UUCP: andrew@resam.dk, phone: +45 32 32 51 54 \ SAS, RESAM Project Office, CPHML-V, P.O.BOX 150, DK-2770 Kastrup, Denmark > > Read oe as: o <backspace> / (slash) and OE as O <backspace> / (slash) < <
ddickey@aspen04.cray.com (Dan A. Dickey) (02/09/91)
In article <1991Feb7.145027.7958@resam.dk>, andrew@resam.dk (Leif Andrew Rump) writes: |> I received three (3) answers to my original very interesting post. :-) |> YOU CAN DO BETTER - and I don't accept cheating like making the |> Reset button inactive or changing it to a Reset button, etc.!!! :-( |> |> Well instead of writing the whole thing one more time I'll ask only |> for some suggestions on how to prevent busy waiting if I have the |> following code (stolen from p.400 in Volume Seven of guess what!): |> |> XFlush(dpy); |> while (!reset_pressed) |> { |> notify_dispatch(); |> XFlush(dpy); |> /* Here is the problem - I don't have any code to put here! */ |> } |> |> The reason I don't have any code to put in is that I'm waiting (using |> notify_set_input_func & notify_set_itimer_func) for some input or the |> timer to time out and I'm using this piece of code because I want to |> stay in the callback routine to keep the button that activated the |> callback routine in busy state... |> |> Any suggestions? - Please! Leif (and others), What is the problem with putting in a select() call? I believe this would be the standard solution...do a select() on the file descriptor associated with the dpy. I believe you can use XConnection() to get this (I'm not sure of the name...there is a macro to get it though). Check your return value from select(), you can get a valid return which means there is something for notify_dispatch() to do, or possibly EINTR which means your itimer interruped the select. Oh, also, you may want to put a timeout value in the select() call... Just to be safe. Anyone see any problems with this? -Dan -- --------- Dan A. Dickey ddickey@fizban.cray.com, or ddickey@aspen.cray.com