From: Jerzy K. <jer...@un...> - 2011-11-02 19:39:48
|
Bruce Sherwood : > I'm not sure I follow all the issues here, but I do want to emphasize > as James Mueller points out that rate is NOT an equivalent of sleep. > Its purpose is to put an upper bound on the rate (...) Alright, no point in continuing. This is my last message on this subject. I didn't say a single word about the purpose of rate()! You are right, but it doesn't change anything in my messages. However, rate()*IS* more or less based on sleep(), and if you do not agree, look at the code : rate.cpp: rate_timer::rate_timer() { origin = sclock(); } void rate_timer::delay(double delay) { float t = delay - (sclock() - origin); if (t > 0.010) { *threaded_sleep(t);* } else while (delay - (sclock() - origin) > 0); origin = sclock(); }; It simply computes the sleep time according to the specification of rate. I claimed ONLY that cvisual seems to use one shared timer, and it precludes the asynchronous animation. Moreover the last while loop suggests that for delays smaller than 0.01 sec, the handler simply enters an idle loop, doing nothing. This is not the most excellent solution, since it blocks /everything/ (only the OS preemption breaks this loop). Perhaps J. Brandmayer could say something about the possibilities to rationalize this. (His name is cited as the author of the code.) I suggested to use time.sleep() as a replacement, practically *it works*, and that's all. I believe that the handling of events by VPython could be discussed, and perhaps modernized a bit as well, but another time. Thank you, everybody. Over. Jerzy Karczmarczuk Caen, France |