× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On Mon, Mar 19, 2018 at 10:11 AM, Kelly Cookson <KCookson@xxxxxxxxxxxx>
wrote:

Henrik,

Being a newbie, I am curious. Why would I want to use Node if I’m not
leveraging the event loop with asynchronous programming?


I'm not aware of any way to avoid the event loop in Node.js. It appears
that you can block the cycle from running by coding something like a tight
for-loop (i.e. for i = 1 to 100000000). That would be bad form, of course.
Something like that would block any other scripts from running in that
server. If you ran that in the master process that had forked a set of
child processes, then it would block any inter-process communication that
any applications may rely on.

Perhaps Henrik hadn't put much thought into his message. It wasn't clear
(to me at least) whether his reference to asynchronous programming was in
regard to the new "async" and "await" keywords which make functions appear
to wait for things like DB I/O to occur. They don't actually wait. It's
just a clever way to implement callbacks in Node.js without passing a
reference to callback functions. The actual callback is to the same
function code following the "await" keyword. The function appears to resume
where it left off during an I/O operation, or the like. Several cycles of
the event loop could have actually occurred in between, while the I/O had
actually been passed off to another thread in the thread pool.

I understand in theory that I could have an instance of the event loop
running that processes a batch script instead of handing it off to worker
threads. But that why would I want to do that? I’m genuinely curious since
I’m still learning and this may be a failure of my imagination.


I'm curious too. Particularly if the "batch script" were performing any DB
I/O. Why would you do that in Node.js?

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.