Rah*_*kla 6 multithreading callback node.js
我是nodeJS和节点扩展的新手.我正在为节点js编写一个本机扩展,它将在虚函数OnEvent(param1,param2,param3)上接收回调.代码如下:
bool MyExt::OnEvent(int eventType, string param1, string param2)
{
printf("MyExt:: onevent___ \n");
{
//// Crashes here, but if I use Locker, it get stuck!!!!!!
//Locker l;
Local<Value> argv[3] = {
Local<Value>::New(Integer::New(1)),
Local<Value>::New(String::New("parameter 1")),
Local<String>::New(String::New("parameter 2"))
};
TryCatch try_catch;
//// I need to call this
m_EventCallback->Call(Context::GetCurrent()->Global(), 3, argv);
if (try_catch.HasCaught()){
printf("Callback is Exception() \n");
}
printf("Callback is IsCallable() \n");
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
我需要使用m_EventCallback将此回调参数转发到服务器脚本.函数bool OnEvent是从另一个线程调用的.
我尝试使用uv_async_send但无法成功.
任何帮助或指导将不胜感激.
使用uv_async_send是正确的方法:
http://nikhilm.github.com/uvbook/threads.html
| 归档时间: |
|
| 查看次数: |
3048 次 |
| 最近记录: |