首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

libuv的多线程有关问题

2013-08-16 
libuv的多线程问题原文:http://stackoverflow.com/questions/13838972/is-libuv-thread-safe?answertabvo

libuv的多线程问题

原文:http://stackoverflow.com/questions/13838972/is-libuv-thread-safe?answertab=votes#tab-top

?

I have created a new thread dedicated to a libuv run loop. The thread function looks something like this:

uv_async_send(&exit_handle);

?

You need to take care to not call?uv_async_send()?before the other thread has finished setting up the loop and the uv_async handle. Recent version of libuv include the?uv_barrier?synchronization primitives that you could use; but the libuv version that ships with Node.js 0.8 doesn't support this yet, so you probably need to use pthread facilities to make this work.

On a side note, you seem to be calling?uv_ref?and?uv_unref?with a loop reference as the argument. In recent versions of libuv this has changed, you are now supposed to?uv_ref?and?uv_unref?a specific handle. See?uv.h?for details.

热点排行