Re: Threads

Jerzy Karczmarczuk <[email protected]>
Newsgroups gmane.comp.python.visualpython.user
Organization UCBN
Message-ID <[email protected]>
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

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1

_______________________________________________
Visualpython-users mailing list
Visualpython-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/visualpython-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.