mirror of
https://github.com/denoland/deno.git
synced 2025-09-30 06:04:48 +00:00
feat: support SharedArrayBuffer sharing between workers (#11040)
This commit adds support for sharing SABs between workers.
This commit is contained in:
parent
672a88f272
commit
bdfad23dd0
13 changed files with 152 additions and 0 deletions
|
@ -43,6 +43,7 @@ async fn main() -> Result<(), AnyError> {
|
|||
origin_storage_dir: None,
|
||||
blob_store: BlobStore::default(),
|
||||
broadcast_channel: InMemoryBroadcastChannel::default(),
|
||||
shared_array_buffer_store: None,
|
||||
};
|
||||
|
||||
let js_path =
|
||||
|
|
|
@ -28,6 +28,7 @@ use deno_core::ModuleId;
|
|||
use deno_core::ModuleLoader;
|
||||
use deno_core::ModuleSpecifier;
|
||||
use deno_core::RuntimeOptions;
|
||||
use deno_core::SharedArrayBufferStore;
|
||||
use deno_web::create_entangled_message_port;
|
||||
use deno_web::BlobStore;
|
||||
use deno_web::MessagePort;
|
||||
|
@ -269,6 +270,7 @@ pub struct WebWorkerOptions {
|
|||
pub get_error_class_fn: Option<GetErrorClassFn>,
|
||||
pub blob_store: BlobStore,
|
||||
pub broadcast_channel: InMemoryBroadcastChannel,
|
||||
pub shared_array_buffer_store: Option<SharedArrayBufferStore>,
|
||||
}
|
||||
|
||||
impl WebWorker {
|
||||
|
@ -351,6 +353,7 @@ impl WebWorker {
|
|||
startup_snapshot: Some(js::deno_isolate_init()),
|
||||
js_error_create_fn: options.js_error_create_fn.clone(),
|
||||
get_error_class_fn: options.get_error_class_fn,
|
||||
shared_array_buffer_store: options.shared_array_buffer_store.clone(),
|
||||
extensions,
|
||||
..Default::default()
|
||||
});
|
||||
|
|
|
@ -22,6 +22,7 @@ use deno_core::ModuleId;
|
|||
use deno_core::ModuleLoader;
|
||||
use deno_core::ModuleSpecifier;
|
||||
use deno_core::RuntimeOptions;
|
||||
use deno_core::SharedArrayBufferStore;
|
||||
use deno_web::BlobStore;
|
||||
use log::debug;
|
||||
use std::env;
|
||||
|
@ -70,6 +71,7 @@ pub struct WorkerOptions {
|
|||
pub origin_storage_dir: Option<std::path::PathBuf>,
|
||||
pub blob_store: BlobStore,
|
||||
pub broadcast_channel: InMemoryBroadcastChannel,
|
||||
pub shared_array_buffer_store: Option<SharedArrayBufferStore>,
|
||||
}
|
||||
|
||||
impl MainWorker {
|
||||
|
@ -136,6 +138,7 @@ impl MainWorker {
|
|||
startup_snapshot: Some(js::deno_isolate_init()),
|
||||
js_error_create_fn: options.js_error_create_fn.clone(),
|
||||
get_error_class_fn: options.get_error_class_fn,
|
||||
shared_array_buffer_store: options.shared_array_buffer_store.clone(),
|
||||
extensions,
|
||||
..Default::default()
|
||||
});
|
||||
|
@ -300,6 +303,7 @@ mod tests {
|
|||
origin_storage_dir: None,
|
||||
blob_store: BlobStore::default(),
|
||||
broadcast_channel: InMemoryBroadcastChannel::default(),
|
||||
shared_array_buffer_store: None,
|
||||
};
|
||||
|
||||
MainWorker::from_options(main_module, permissions, &options)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue