|
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 workersince
threads. But that why would I want to do that? I’m genuinely curious
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?
--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing
list
To post a message email: WEB400@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/web400.
As an Amazon Associate we earn from qualifying purchases.
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.