Polling is not used.
does it block the event loop?
It will if you use the sync versions. For example, using readFileSync
will block other JS from running until the file is read and comes back. This could well be a problem if multiple parts of the script call such a method at different times.
But if you use the asynchronous versions (for example, readFile
) which either accept a callback or return a Promise, they will not block other JS from running while the file operation is going on.
When in doubt, use one of the asynchronous versions - I'd only use the sync versions for smaller apps with segments of code that will only run once, such as for the initial reading of a config file, for which preventing other JS from running during that one-time delay isn't an issue.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…