(util1, util2)
| 697 | } |
| 698 | |
| 699 | function eventLoopUtilization(util1, util2) { |
| 700 | // TODO(trevnorris): Works to solve the thread-safe read/write issue of |
| 701 | // loopTime, but has the drawback that it can't be set until the event loop |
| 702 | // has had a chance to turn. So it will be impossible to read the ELU of |
| 703 | // a worker thread immediately after it's been created. |
| 704 | if (!this[kIsOnline] || !this[kHandle]) { |
| 705 | return { idle: 0, active: 0, utilization: 0 }; |
| 706 | } |
| 707 | |
| 708 | // Cache loopStart, since it's only written to once. |
| 709 | if (this[kLoopStartTime] === -1) { |
| 710 | this[kLoopStartTime] = this[kHandle].loopStartTime(); |
| 711 | if (this[kLoopStartTime] === -1) |
| 712 | return { idle: 0, active: 0, utilization: 0 }; |
| 713 | } |
| 714 | |
| 715 | return internalEventLoopUtilization( |
| 716 | this[kLoopStartTime], |
| 717 | this[kHandle].loopIdleTime(), |
| 718 | util1, |
| 719 | util2, |
| 720 | ); |
| 721 | } |
| 722 | |
| 723 | module.exports = { |
| 724 | ownsProcessState, |
no test coverage detected
searching dependent graphs…