Async Programming

11 thoughts
last posted Jan. 9, 2013, 12:02 p.m.

8 earlier thoughts

0

What, then, of the yield from based coroutine part of tulip? One of the core problems with callback-based cooperative multi-threading development is that it doesn't fit the way people think very well. Preemptive multi-threading piggy backs pretty well on our intuitive ideas of autonomous agents doing their own thing in parallel with each other. Event-driven programming with callbacks, on the other hand, can make it hard to see how a single operation flows from beginning to end.

Twisted's inlineDeferred's use generators to adapt between a callback based event loop and generators that exhibit linear control flow with clearly marked points for possible suspension. tulip's coroutines serve exactly the same purpose - rather than dealing with callbacks explicitly, it's possible to write code that shows the end-to-end handling of the operation, while still have local markers indicating where the operation may be suspended.

2 later thoughts