mirror of
https://github.com/denoland/deno
synced 2024-10-30 02:21:11 +00:00
79b3bc05d6
* establish basic event loop for workers * make "self.close()" inside worker * remove "runWorkerMessageLoop() - instead manually call global function in Rust when message arrives. This is done in preparation for structured clone * refactor "WorkerChannel" and use distinct structs for internal and external channels; "WorkerChannelsInternal" and "WorkerHandle" * move "State.worker_channels_internal" to "Worker.internal_channels" * add "WorkerEvent" enum for child->host communication; currently "Message(Buf)" and "Error(ErrBox)" variants are supported * add tests for nested workers * add tests for worker throwing error on startup
19 lines
449 B
Rust
19 lines
449 B
Rust
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
|
|
|
pub fn create_basic_runtime() -> tokio::runtime::Runtime {
|
|
tokio::runtime::Builder::new()
|
|
.basic_scheduler()
|
|
.enable_io()
|
|
.enable_time()
|
|
.build()
|
|
.unwrap()
|
|
}
|
|
|
|
// TODO(ry) rename to run_local ?
|
|
pub fn run_basic<F, R>(future: F) -> R
|
|
where
|
|
F: std::future::Future<Output = R> + 'static,
|
|
{
|
|
let mut rt = create_basic_runtime();
|
|
rt.block_on(future)
|
|
}
|