Comments (2)
这里并没有让代码并发执行,仅仅是一种跳出去再跳回来的跳转逻辑而已,算不上协程。
用yield实现并发的协程,语言要支持异步的IO或者计算才行,PHP在这一块的支持是很薄弱的。
对多个middleware的调用逻辑可以看\Owl\Middleware的execute()方法 (https://github.com/yeaha/owl-core/blob/master/src/Middleware.php#L69)
简单说明一下流程就是:
- 依次call每个middleware function
- 观察返回值是否一个Generator对象,因为允许middleware执行一次完事,不用再跳进去
- 调用Generator::current()检查返回值,如果是false说明这个middleware逻辑决定中断整个链条继续执行
- 把拿到的Generator放到一个先进后出的栈里
- 所有middleware执行完之后,把依次调用栈里的Generator::next()方法执行每个middleware剩余逻辑
from owl.
哇撒,谢谢杨老师 🎉
from owl.
Related Issues (2)
- 报Not Found 错误 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from owl.