Can I do custom events with libuv?

Can I do custom events with libuv?

Problem

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!

Problem courtesy of: Verdagon

Solution

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.

http://nikhilm.github.com/uvbook/threads.html

Solution courtesy of: laktak

Discussion

Leave a Reply

Your email address will not be published. Required fields are marked *