Skip to content
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

Open
cekkr opened this issue Apr 7, 2022 · 6 comments
Open

Release the job after every cycle #167

cekkr opened this issue Apr 7, 2022 · 6 comments

Comments

@cekkr
Copy link

cekkr commented Apr 7, 2022

Has sense to implement a sched_yield() at every cycle in loopWhile() for making the loop a "little less blocking"?

Thank you

@jardicc
Copy link

jardicc commented Apr 7, 2022

Could you please elaborate a bit more about benefit of this? Maybe some real world example?

@cekkr
Copy link
Author

cekkr commented Apr 7, 2022 via email

@cekkr
Copy link
Author

cekkr commented Apr 7, 2022 via email

@cekkr
Copy link
Author

cekkr commented Apr 7, 2022

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.
But my logic is that: if you are waiting for a callback result you are respecting the I/O event-driven logic of node and you are using deasync just for implement in the most simplest way a form of "await". So, excluding a paralled heavy calculation inside the same context, my question if it's implemented a sort of sched_yield for making the thread more less CPU time occupier than possible.

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?

@cekkr
Copy link
Author

cekkr commented Apr 7, 2022

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

@jardicc
Copy link

jardicc commented Apr 8, 2022

I have just very little knowledge about this topic. But maybe could you fork it and see how it goes for yourself? :-)
You can always wrap callback into promise but then all parent functions in callstack has to be changed into async/await too to keep things in correct order. You have to change getters/setters into classic functions and whole codebase can get messy.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants