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