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

Firing the callback and getting the result asynchronously #6

Open
Globik opened this issue Mar 29, 2018 · 2 comments
Open

Firing the callback and getting the result asynchronously #6

Globik opened this issue Mar 29, 2018 · 2 comments
Labels

Comments

@Globik
Copy link

Globik commented Mar 29, 2018

Is this operation an analog of uv_queue_work() function? If yes, should it work with last commit and without uv_async_send?

@kroggen
Copy link
Collaborator

kroggen commented Mar 30, 2018

It is similar.

The uv_queue_work() uses a worker thread pool and we don't need to configure them.

The asynchronous call in uv_callback calls the function from another single thread that has its own loop.

We use the last option when we set the app with more than a single thread loop and we have the control to which thread the call will be made.

@Globik
Copy link
Author

Globik commented Mar 30, 2018

Thank you for reply @kroggen , now I understand.
I've tried uv_callback in conjuction with uv_queue_work() (is it a bad practice?) with the same loop for both. Surprisingly for me I've found it works. (Without uv_async_send(&async) of course) . I've merked also that the uv_callback's callbacks are firing an event just like in node.js EventEmmiter().emit('my_event', data) does in a single thread loop.

But by now I didn't yet figured out all features of this approach. Just a little hello_world.c with uv_queue_work() and uv_callback all together I've written for me.

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

No branches or pull requests

3 participants
@kroggen @Globik and others