Verdagon
Verdagon

Reputation: 2630

Can I do custom events with libuv?

I'm looking to try out libuv, but I need to be able to send events from my networking thread to my main thread. I'm guessing libuv would have custom events to handle this sort of thing but I can't find them.

Any ideas? Thanks!

Upvotes: 4

Views: 2293

Answers (1)

laktak
laktak

Reputation: 60043

You can send them using uv_async_send:

  • Call uv_async_init on the 'main' thread.
  • Then call uv_async_send from your worker.
  • Don't forget uv_close back on main.

Reference: https://docs.libuv.org/en/v1.x/guide/threads.html

Upvotes: 5

Related Questions