Hi,

I am currently started experimenting with V8 and have a few issues 
regarding the proper registration of extensions.

With the experiment itself I am trying to use actors [1] executing 
javascript for multithreading. The javascript would
define the behaviour of the actor (i.e. on what events the actor should 
react and what should be done after receiving 
such an event). Every actor is currently using an individual isotope. 
Because for certain tasks (i.e. IO) multiple actors
will be spawned, I figured avoiding the recompilation for a known actor 
type would be overhead.

In this [2] previous thread I stumbled upon the method using extensions to 
avoid the recompilation of scripts.

The experiment's code can be found on github and the dev branch contain the 
extension related changes [3].

The code is compiling, but if executed V8 traces the following error:
#
# Fatal error in v8::Context::New()
# Cannot find required extension
#

The function registering the extension and returning the configuration 
looks as following:
------------------------------------------------------------------------------------------------------------
map<string, shared_ptr<Extension>> extension_map;

unique_ptr<ExtensionConfiguration> get_extension_configuration(const string 
&file) {
    if (extension_map.find(file) == extension_map.end()) { // TODO: 
possible memory issue
        ifstream file_stream(file.c_str());
        if (!file_stream) {
            aout << "Error: Unable to open file: " << file << endl;
            return NULL;
        }
        string file_source;    
        file_stream.seekg(0, std::ios::end);   
        file_source.reserve(file_stream.tellg());
        file_stream.seekg(0, std::ios::beg);
        file_source.assign((std::istreambuf_iterator<char>(file_stream)), 
std::istreambuf_iterator<char>()); 
        
        shared_ptr<Extension> extension(new Extension(file.c_str(), 
file_source.c_str(), 0, 0, file_source.size()));
        extension_map[file] = extension;       
        RegisterExtension(extension.get()); 
    }
    const char* extensions[] = { file.c_str() };
    return unique_ptr<ExtensionConfiguration>(new ExtensionConfiguration(1, 
extensions));
}
------------------------------------------------------------------------------------------------------------

The implementation is based on the JSExtension implementation of pyv8 [4]. 
V8 was installed without any errors using brew install v8 on OSX.

Unfortunately I am unable to find any good documentation on this problem:
* How can I successfully register an extension?
* If a context is composed out of extensions only is it possible to execute 
the context without a script?
* Is it possible to share and object template between multiple threads and 
isotopes (avoid the reconstruction)?


Thanking you in anticipation,
Niklas Voss

P.S. Any help or links to relevant articles are very much appreciated. Also 
if you need more information let me know!


[1] https://github.com/Neverlord/libcppa
[2] 
https://groups.google.com/forum/?fromgroups#!searchin/v8-users/source$20share/v8-users/TMTcI10G6Zc/40TjfruWJsUJ
[3] https://github.com/trevex/veta/blob/dev/src/main.cc
[4] https://code.google.com/p/pyv8/source/browse/trunk/src/Engine.cpp

-- 
-- 
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.

Reply via email to