<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
On 4/17/10 4:34 PM, Andrew Tutt wrote:
<blockquote
 cite="mid:p2yd23f42ab1004170934t12d9160ub1474f8f0badb231@mail.gmail.com"
 type="cite"><span class="Apple-style-span"
 style="font-family: arial,sans-serif; font-size: 13px; border-collapse: collapse;">
  <div>This idiom has probably already been contributed, but the
following code implements "interruptable wait" which could also be
thought of the opposite way, as implementing receive() with a timeout.&nbsp;</div>
  <div><br>
  </div>
  <div>Also, I've taken the liberty on the following code of actually
using a small sleep call between schedules. This, I have found
massively decreases CPU load while altering my performance very little.
Your results may vary, but as you may already be aware, there is no way
that I can think of that one can implement sleep that is not busy in
stackless, so this is the next best thing. You could easily extend it
to make it tweak the length of the time.sleep based on load of course.</div>
  </span></blockquote>
<tt>Without looking at the code now, who says that a non-busy sleep<br>
cannot be implemented? Make a timer class with a singleton<br>
instance that keeps track of all sleepers. As soon as all<br>
but one tasklets are sleeping, the last tasklet can compute<br>
the time until one will wake up, and really sleep for that period.<br>
<br>
ciao - chris<br>
</tt>
<pre class="moz-signature" cols="72">-- 
Christian Tismer             :^)   <a class="moz-txt-link-rfc2396E" href="mailto:tismer@stackless.com">&lt;mailto:tismer@stackless.com&gt;</a>
tismerysoft GmbH             :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9A     :    *Starship* <a class="moz-txt-link-freetext" href="http://starship.python.net/">http://starship.python.net/</a>
14109 Berlin                 :     PGP key -&gt; <a class="moz-txt-link-freetext" href="http://wwwkeys.pgp.net/">http://wwwkeys.pgp.net/</a>
work +49 30 802 86 56  mobile +49 173 24 18 776  fax +49 30 80 90 57 05
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?   <a class="moz-txt-link-freetext" href="http://www.stackless.com/">http://www.stackless.com/</a></pre>
</body>
</html>