<div>Hi Arnar,</div>
<div> </div>
<div>You said, "There have been discussions here occasionally about something generic, like wrapping libevent or similar in an interface that "looks" synchronous but in the background does async I/O and uses channels to make it look synchronous." That is of course what this does. Points:</div>
<div> - "There have been discussions" implies a blocking point ;-) This is a design that is complete. simple, and proven, and could be put in the virtual machine tomorrow.</div>
<div> - The notion of "asynchronous IO" is vague and, in the typical manner, therefore threatens to complicate matters with a huge palette (your "myriad") of explicit tools that work at cross-purposes. By contrast, the first phase of this design (Channel Communication plus Hardware Select) would result in NO VISIBLE CHANGE, no libraries - just a clearing of the "blocking" logjam and freedom for other tasklets to run efficiently while the hardware wait is going on, just as David wanted.</div>
<div> - There is also no visible change if you add the second phase, "Timer": the sleeping tasklet (or simultaneously sleeping tasklets) would take no blocking time on the round robin. (Your time.sleep code indicates this is not currently the case - am I right, or does Py_BEGIN_ALLOW_THREADS set up a separate queue?)</div>
<div> - The complication added by these phases is in the virtual machine only: a couple of new queues (channel and timer) in addition to Stackless's round robin scheduler. The channel queues have maximum length 1. I am assuming that "tasklet" = "process" in the sense I defined in the note (which certainly appears to be the case, with the examples you gave). I am also assuming there is some memory dedicated to the tasklet for its whole life (but I can't imagine anything being "stackless" without that!).</div>
<div> - The only thing that would create a new visible interpreted code option would be the last phase, the user-level ALT or select. And that could be done in any way that people like: for instance, as a standard Unix-like select call, or a transputer-like ALT branching on readiness of IO channels. In my experience, that is the central key to any serious parallel coding (changing disorder into order, as it were).</div>
<div> - And all without a myriad: the only other such structure that I've ever found useful is a simple binary semaphore (which works just like the timer queue, and avoids the ALT/select overhead in a common case). That could be added later.</div>
<div> - The only question is whether something about the object structure forbids input from several channels in one tasklet.</div>
<div> </div>
<div>Larry<br><br> </div>
<div><span class="gmail_quote">On 10/9/08, <b class="gmail_sendername">Arnar Birgisson</b> <<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:arnarbi@gmail.com" target="_blank">arnarbi@gmail.com</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hi Larry,<br><br>On Fri, Oct 10, 2008 at 00:54, Larry Dickson <<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:ldickson@cuttedge.com" target="_blank">ldickson@cuttedge.com</a>> wrote:<br>
> On Fri, Sep 26 17:09:54 CEST 2008, Arnar Birgisson <arnarbi at <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://gmail.com/" target="_blank">gmail.com</a>><br>>> > Surely there is a way around this? Some kind of pooling select? If<br>
>> > there is<br>>> > no work around then I cannot see too much practical use for my thread<br>>> > library<br>>> > [except having to avoid learning tasklets for someone who is familiar<br>
>> > with<br>>> > threads]. As I understand it, due to the GIL the only real practical<br>>> > use for<br>>> > threads is if one has blocking function calls (IO-type, etc)<br>>><br>
>> The solution would be asynchronous I/O. There have been discussions<br>>> here occasionally about something generic, like wrapping libevent or<br>>> similar in an interface that "looks" synchronous but in the background<br>
>> does async I/O and uses channels to make it look synchronous. I figure<br>>> such a thing would be an excellent component of your thread library.<br>>><br>>> > [Has the GIL restriction been fixed in 3k? As far as I know Jython does<br>
>> > not<br>>> > have this limitation...]<br>>><br>>> The GIL has not been removed in Py 3.0, nor will it be removed any<br>>> time soon. Jython does not have such a thing.<br>><br>> This design solves all these problems, using only C/Unix select (which you<br>
> pointed out is already used to do time.sleep) in the virtual machine; and<br>> it runs in only one thread. There is no need to remove the GIL.<br><br>What problems? If you read my message you can clearly see that I<br>
pointed to a _solution_, namely asynchronous I/O. :) What I meant in<br>my last message is that I don't see how your suggestion improves on<br>the myriad of async solutions out there already (which are based on<br>select, poll, epoll, Windows ASIO, etc).<br>
<br>cheers,<br>Arnar<br></blockquote></div><br>