Hello, im trying to bind a download function but i get fatal error in api.h
line 549 CHECK(blocks_.length() == 0)
also my english is bad (sry)
my program goes like that
main thread call jsMainFunction
jsMainFunction
----
function jsMainFunction ()
{
_get("www.google.com",true,
function(data){
print("downloaded: ",data);
}
);
}
---
jsMainFunction call native downloadfunction (_BindDownloadGet aka _get)
----
v::Handle<v::Value> _BindDownloadGet(const v::Arguments& args)
{
....
if(args.Length() == 3
&& args[0]->IsString()
&& args[1]->IsBoolean()
&& args[1]->ToBoolean()->BooleanValue()
&& args[2]->IsFunction()
)
{
//async
v::Persistent<v::Function> funcCopy =
v::Persistent<v::Function>::New(
v::Handle<v::Function>::Cast(args[2])
);
void* fp = new std::function<void(void)>(
[=]()
{
v::Locker locker(gIsolate);
v8::Isolate::Scope scope(gIsolate);
std::vector<char> data = Download(url);
v::Handle<v::Value> arg = v::String::New(data.data(),data.size());
funcCopy->Call(gContext->Global(),1,&arg);
}
);
CreateThread(0,0,_WinCallbackHost,fp,0,0);
return v::Undefined();
}
//sync
std::vector<char> data = Download(url);
return v::String::New(data.data(),data.size());
}
----
(the _WinCallbackHost its just call lambda and deleteing the fp)
The program is downloading the data and printing that data, but when locker
destructor is called the program crash with fatal error
PS
this is the print binding
v::Handle<v::Value> _BindWriteConsole(const v::Arguments& args)
{
for(int i = 0; i < args.Length(); i++)
if(args[i]->IsString())
StockObserverConsoleWrite(Utf8ToWide(*v::String::Utf8Value(args[i])));
return v::Undefined();
}
PS1: Its a native win32 gui application
PS2: visual studio 2012
PS3: windows 7
PS4: Sorry fro my bad english
--
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.