mirror of
https://github.com/goldbergyoni/nodebestpractices.git
synced 2025-10-27 19:17:13 +08:00
Reflecion of #589
This commit is contained in:
@ -6,13 +6,13 @@ Node обрабатывает цикл событий в основном в о
|
||||
|
||||
### Example: blocking the event loop
|
||||
Давайте посмотрим на пример из [Node Clinic](https://clinicjs.org/documentation/doctor/05-fixing-event-loop-problem).
|
||||
```
|
||||
```javascript
|
||||
function sleep (ms) {
|
||||
const future = Date.now() + ms
|
||||
while (Date.now() < future);
|
||||
}
|
||||
|
||||
server.get('/', function (req, res, next) {
|
||||
server.get('/', (req, res, next) => {
|
||||
sleep(30)
|
||||
res.send({})
|
||||
next()
|
||||
|
||||
Reference in New Issue
Block a user