-
-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release the job after every cycle #167
Comments
Could you please elaborate a bit more about benefit of this? Maybe some real world example? |
The concept is this: I use deasync for programming simplification (and
mainly laziness). The best use of node infact is through callbacks.
But my worry is about the fact that a loop could use too many CPU
resources.
So offering the possibility to release the thread at every cycle you can
check if the loop should continue just when the probability that loop
conditions are changed is higher.
But a similar implementation (this is must done directly in deasync) can be
useful just if every time the thread is in execution continues to check the
same condition occupying the processor for repeating an operation that
probabilistically has the same result in the short term.
With a similar feature you are more relaxed about the fact you are using a
blocking loop in node but taking less CPU resources as possible.
|
This feature is also useless if V8 use to execute every code and callback
in the script with just one thread.
In this case should be implemented a function that allows releasing the
loop from the execution of the engine for passing to the next "operation
stack"
|
Forgive me, I'm trying to connect my brain. If a js script context runs on one only thread it's obvious that deasync for allowing the execution of other callbacks should allow to block the execution flow without be fully blocking. Whenever I use deasync I can only think of the criticisms I have received for using a blocking function in an I / O driven system. So with an implementation like this I could part my heart in peace. Can I explain myself? |
Finally @jardicc I do not hide that I would learn better how V8 and modules like deasync work for various reasons, including knowing how to obtain the maximum possible performance |
I have just very little knowledge about this topic. But maybe could you fork it and see how it goes for yourself? :-) But at the same time if you are running server and you wait for deasync function to finish then server is simply frozen and unable to reply during deasync execution leading to errors and problems. So having something in between would amazing. But I am not C++ guy so I don't know whether this is possible or not. |
Has sense to implement a sched_yield() at every cycle in loopWhile() for making the loop a "little less blocking"?
Thank you
The text was updated successfully, but these errors were encountered: