Cooperative multitasking with generators
summary
Shows how PHP generators (added in PHP 5.5) let functions yield pauses and resumes execution so a file reader holds only one line in memory and a bubble-sort can emit intermediate steps; builds a cooperative multitasker in about 64 lines of code that runs tasks interleaved in one thread (asynchronous not parallel). Demonstrates use of amp, react PHP and recoil, and an actual site (pre-process dot IO) using generators with promises to run a non-blocking HTTP server in production.
AI-written summary · about
chapters (11)
- 0:00Introduction
- 1:05What about arrays
- 4:22Implementing iterator
- 10:17Implementing generators
- 13:51Bubble sorting
- 20:53Data tables
- 22:09Task manager
- 26:07Generator
- 30:58Recap
- 32:14Nonblocking code
- 41:52Conclusion
related talks
38mAsync advantage with Sync simplicity
35mInterators + Generatiors: The Road to Virtual Infinite RAM
20mIt's Critical: Concurrent programming as a sane programming model
25mAsync PHP with Coroutines: Building Scalable Applications
50mImproving Application Performance with ReactPHP
25mCrazy Fun Experiments with PHP (Not for Production)
37mLet's Program Like It's 1999
45mPHP Reactive Programming
