Fibrils and asynchronous system calls
Posted Feb 2, 2007 2:27 UTC (Fri) by pimlott
In reply to: Fibrils and asynchronous system calls
Parent article: Fibrils and asynchronous system calls
It reminds me of call/cc in functional programming
Bingo, I was hoping someone would say that. The functional world has some nice mechanisms for handling concurrency. For example you can express an IO operation as a description of the request, plus a function to run on the result (and this is natural with lambda and lexical closure). The runtime can manage all outstanding requests and pass the responses to the functions as they become available. Similarly, a driver can be expressed as a computation that returns either an answer, or a message indicating what resource it needs before it can continue, plus a function to run on that resource. The runtime again obtains the needed resources and runs the continuations. You get most of the benefit of event-driven programming, with the illusion of sequential processing (outside the runtime).
I'm reminded of Alan Cox's quote, "Computers are state machines. Threads are for people who can't program state machines." To which the best programmer I've ever known answered, "I can't program state machines!" The appearance of sequential execution is a boon to programmer productivity.
to post comments)