-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Add WebWorker API #1261
[WIP] Add WebWorker API #1261
Conversation
Interesting! v8::Shell functions have to be copied over. Start a new file called libdeno/worker.cc and add them. You can grep for the locations in third_party/v8
|
I started with
Is that the right direction @ry? |
Ya - you will have to make some heavy modifications to get it to work. I will give some more detailed comments later Be sure to update build.gn with the new source file |
Awesome! |
Just curious (sorry for not really following the discussion about workers recently in Node), are we going to have separate event loops for each worker thread, or are we going to share a single event loop across all worker threads? Also I believe we also need to implement messaging together with Workers |
It should match the specification IMO, which is a seperate event loop. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is obviously a larger project - and I'm glad you're starting it - so far so good. Maybe add tests/worker.js
with an extremely simple worker test - and see how far you can get towards running it. Feel free to ping me on gitter or email for help.
@@ -30,12 +30,13 @@ Deno* deno_new(deno_buf snapshot, deno_buf shared, deno_recv_cb cb) { | |||
v8::Locker locker(isolate); | |||
v8::Isolate::Scope isolate_scope(isolate); | |||
{ | |||
v8::Local<v8::ObjectTemplate> global_template = | |||
deno::CreateGlobalTemplate(isolate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works. I would consider using our existing deno::InitializeContext
for setting up the global variables... However using a ObjectTemplate is probably a better option - and how D8 is doing it - so don't worry about this nit for now.
7fd578d
to
8e9c36a
Compare
@ry I've started with your feedback. I put some placeholder methods (like
Digging further! |
@bartlomieju In V8's binding API, basically every function needs to declare a HandleScope for storing local variables. I suggest reading https://v8.dev/docs/embed
|
@kevinkassimo Sorry didn't see your message until now. I'd like the different workers to share the same Tokio runtime. |
Thanks for tips @ry great read. There is some progress now, actual worker instantiation is called (run |
I've started an alternative implementation in rust here #1331 |
Closing in favor of #1331 |
Ref #1222
ATM I am getting this error during build: